home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / awksrc.zip / AWKTAB~1.C < prev    next >
C/C++ Source or Header  |  1993-09-26  |  106KB  |  3,232 lines

  1.  
  2. /*  A Bison parser, made from awk.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    FUNC_CALL    258
  7. #define    NAME    259
  8. #define    REGEXP    260
  9. #define    ERROR    261
  10. #define    YNUMBER    262
  11. #define    YSTRING    263
  12. #define    RELOP    264
  13. #define    APPEND_OP    265
  14. #define    ASSIGNOP    266
  15. #define    MATCHOP    267
  16. #define    NEWLINE    268
  17. #define    CONCAT_OP    269
  18. #define    LEX_BEGIN    270
  19. #define    LEX_END    271
  20. #define    LEX_IF    272
  21. #define    LEX_ELSE    273
  22. #define    LEX_RETURN    274
  23. #define    LEX_DELETE    275
  24. #define    LEX_WHILE    276
  25. #define    LEX_DO    277
  26. #define    LEX_FOR    278
  27. #define    LEX_BREAK    279
  28. #define    LEX_CONTINUE    280
  29. #define    LEX_PRINT    281
  30. #define    LEX_PRINTF    282
  31. #define    LEX_NEXT    283
  32. #define    LEX_EXIT    284
  33. #define    LEX_FUNCTION    285
  34. #define    LEX_GETLINE    286
  35. #define    LEX_IN    287
  36. #define    LEX_AND    288
  37. #define    LEX_OR    289
  38. #define    INCREMENT    290
  39. #define    DECREMENT    291
  40. #define    LEX_BUILTIN    292
  41. #define    LEX_LENGTH    293
  42. #define    UNARY    294
  43.  
  44. #line 26 "awk.y"
  45.  
  46. #ifdef DEBUG
  47. #define YYDEBUG 12
  48. #endif
  49.  
  50. #define    YYMAXDEPTH    300
  51. #define    YYSSIZE    YYMAXDEPTH
  52.  
  53. #include "awk.h"
  54.  
  55. static void yyerror (); /* va_alist */
  56. static char *get_src_buf P((void));
  57. static int yylex P((void));
  58. static NODE *node_common P((NODETYPE op));
  59. static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
  60. static NODE *mkrangenode P((NODE *cpair));
  61. static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
  62. static NODE *append_right P((NODE *list, NODE *new));
  63. static void func_install P((NODE *params, NODE *def));
  64. static void pop_var P((NODE *np, int freeit));
  65. static void pop_params P((NODE *params));
  66. static NODE *make_param P((char *name));
  67. static NODE *mk_rexp P((NODE *exp));
  68.  
  69. static int want_assign;        /* lexical scanning kludge */
  70. static int want_regexp;        /* lexical scanning kludge */
  71. static int can_return;        /* lexical scanning kludge */
  72. static int io_allowed = 1;    /* lexical scanning kludge */
  73. static char *lexptr;        /* pointer to next char during parsing */
  74. static char *lexend;
  75. static char *lexptr_begin;    /* keep track of where we were for error msgs */
  76. static char *lexeme;        /* beginning of lexeme for debugging */
  77. static char *thisline = NULL;
  78. #define YYDEBUG_LEXER_TEXT (lexeme)
  79. static int param_counter;
  80. static char *tokstart = NULL;
  81. static char *token = NULL;
  82. static char *tokend;
  83.  
  84. NODE *variables[HASHSIZE];
  85.  
  86. extern char *source;
  87. extern int sourceline;
  88. extern char *cmdline_src;
  89. extern char **srcfiles;
  90. extern int errcount;
  91. extern NODE *begin_block;
  92. extern NODE *end_block;
  93.  
  94. #line 76 "awk.y"
  95. typedef union {
  96.     long lval;
  97.     AWKNUM fval;
  98.     NODE *nodeval;
  99.     NODETYPE nodetypeval;
  100.     char *sval;
  101.     NODE *(*ptrval)();
  102. } YYSTYPE;
  103.  
  104. #ifndef YYLTYPE
  105. typedef
  106.   struct yyltype
  107.     {
  108.       int timestamp;
  109.       int first_line;
  110.       int first_column;
  111.       int last_line;
  112.       int last_column;
  113.       char *text;
  114.    }
  115.   yyltype;
  116.  
  117. #define YYLTYPE yyltype
  118. #endif
  119.  
  120. #include <stdio.h>
  121.  
  122. #ifndef __STDC__
  123. #define const
  124. #endif
  125.  
  126.  
  127.  
  128. #define    YYFINAL        308
  129. #define    YYFLAG        -32768
  130. #define    YYNTBASE    61
  131.  
  132. #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 108)
  133.  
  134. static const char yytranslate[] = {     0,
  135.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,    49,     2,     2,    52,    48,     2,     2,    53,
  139.     54,    46,    44,    60,    45,     2,    47,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,    40,    59,    41,
  141.      2,    42,    39,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.     55,     2,    56,    51,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,    57,    43,    58,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  160.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  161.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  162.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  163.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  164.     36,    37,    38,    50
  165. };
  166.  
  167. static const short yyprhs[] = {     0,
  168.      0,     4,     6,     9,    11,    14,    15,    19,    20,    24,
  169.     27,    30,    33,    35,    38,    41,    43,    45,    47,    49,
  170.     51,    52,    60,    65,    67,    71,    72,    77,    83,    88,
  171.     90,    93,    95,    98,   100,   103,   106,   109,   113,   115,
  172.    122,   131,   140,   151,   161,   164,   167,   174,   179,   183,
  173.    187,   188,   193,   200,   203,   205,   207,   214,   224,   226,
  174.    229,   230,   232,   233,   236,   237,   240,   243,   246,   247,
  175.    249,   251,   255,   257,   260,   264,   265,   267,   268,   270,
  176.    272,   276,   278,   281,   285,   289,   290,   292,   294,   298,
  177.    300,   303,   307,   311,   312,   317,   323,   328,   332,   336,
  178.    340,   344,   346,   349,   353,   357,   361,   365,   371,   373,
  179.    376,   377,   382,   386,   390,   394,   396,   399,   403,   407,
  180.    411,   417,   419,   422,   424,   426,   430,   434,   438,   442,
  181.    446,   450,   453,   457,   458,   464,   469,   471,   476,   479,
  182.    482,   484,   486,   489,   492,   495,   498,   500,   501,   503,
  183.    505,   510,   513,   516,   519,   522,   524,   525,   527,   529
  184. };
  185.  
  186. static const short yyrhs[] = {    82,
  187.     62,    82,     0,    63,     0,    62,    63,     0,     1,     0,
  188.     62,     1,     0,     0,    15,    64,    74,     0,     0,    16,
  189.     65,    74,     0,    15,    76,     0,    16,    76,     0,    71,
  190.     74,     0,    74,     0,    71,    76,     0,    68,    70,     0,
  191.      4,     0,     3,     0,    67,     0,    37,     0,    38,     0,
  192.      0,    30,    69,    66,    53,    85,   104,    82,     0,   102,
  193.     75,   103,   105,     0,    92,     0,    92,   107,    92,     0,
  194.      0,    47,    73,     5,    47,     0,   102,    75,   103,   105,
  195.     82,     0,   102,   103,   105,    82,     0,    77,     0,    75,
  196.     77,     0,     1,     0,    75,     1,     0,    81,     0,   106,
  197.     82,     0,   106,    82,     0,   102,   103,     0,   102,    75,
  198.    103,     0,    80,     0,    21,    53,    92,   104,    82,    77,
  199.      0,    22,    82,    77,    21,    53,    92,   104,    82,     0,
  200.     23,    53,     4,    32,     4,   104,    82,    77,     0,    23,
  201.     53,    87,   106,    92,   106,    87,   104,    82,    77,     0,
  202.     23,    53,    87,   106,   106,    87,   104,    82,    77,     0,
  203.     24,    76,     0,    25,    76,     0,    79,    53,    91,   104,
  204.     84,    76,     0,    79,    88,    84,    76,     0,    28,    87,
  205.     76,     0,    29,    87,    76,     0,     0,    19,    78,    87,
  206.     76,     0,    20,     4,    55,    91,    56,    76,     0,    92,
  207.     76,     0,    26,     0,    27,     0,    17,    53,    92,   104,
  208.     82,    77,     0,    17,    53,    92,   104,    82,    77,    18,
  209.     82,    77,     0,    13,     0,    81,    13,     0,     0,    81,
  210.      0,     0,    41,    96,     0,     0,    42,    92,     0,    10,
  211.     92,     0,    43,    92,     0,     0,    86,     0,     4,     0,
  212.     86,   107,     4,     0,     1,     0,    86,     1,     0,    86,
  213.    107,     1,     0,     0,    92,     0,     0,    89,     0,    94,
  214.      0,    89,   107,    94,     0,     1,     0,    89,     1,     0,
  215.     89,     1,    94,     0,    89,   107,     1,     0,     0,    91,
  216.      0,    92,     0,    91,   107,    92,     0,     1,     0,    91,
  217.      1,     0,    91,     1,    92,     0,    91,   107,     1,     0,
  218.      0,   101,    11,    93,    92,     0,    53,    91,   104,    32,
  219.      4,     0,    92,    43,    31,   100,     0,    31,   100,    83,
  220.      0,    92,    33,    92,     0,    92,    34,    92,     0,    92,
  221.     12,    92,     0,    72,     0,    49,    72,     0,    92,    32,
  222.      4,     0,    92,     9,    92,     0,    92,    41,    92,     0,
  223.     92,    42,    92,     0,    92,    39,    92,    40,    92,     0,
  224.     96,     0,    92,    92,     0,     0,   101,    11,    95,    94,
  225.      0,    94,    33,    94,     0,    94,    34,    94,     0,    31,
  226.    100,    83,     0,    72,     0,    49,    72,     0,    94,    12,
  227.     94,     0,    94,    32,     4,     0,    94,     9,    94,     0,
  228.     94,    39,    94,    40,    94,     0,    96,     0,    94,    94,
  229.      0,    97,     0,    99,     0,    96,    51,    96,     0,    96,
  230.     46,    96,     0,    96,    47,    96,     0,    96,    48,    96,
  231.      0,    96,    44,    96,     0,    96,    45,    96,     0,    49,
  232.     96,     0,    53,    92,   104,     0,     0,    37,    98,    53,
  233.     90,   104,     0,    38,    53,    90,   104,     0,    38,     0,
  234.      3,    53,    90,   104,     0,    35,   101,     0,    36,   101,
  235.      0,     7,     0,     8,     0,    45,    96,     0,    44,    96,
  236.      0,   101,    35,     0,   101,    36,     0,   101,     0,     0,
  237.    101,     0,     4,     0,     4,    55,    91,    56,     0,    52,
  238.     97,     0,    52,   101,     0,    57,    82,     0,    58,    82,
  239.      0,    54,     0,     0,   106,     0,    59,     0,    60,    82,
  240.      0
  241. };
  242.  
  243. #if YYDEBUG != 0
  244. static const short yyrline[] = { 0,
  245.    136,   141,   149,   165,   166,   170,   172,   186,   188,   202,
  246.    208,   214,   216,   218,   231,   240,   242,   244,   254,   255,
  247.    259,   263,   271,   280,   282,   291,   293,   309,   311,   316,
  248.    318,   326,   328,   333,   334,   338,   340,   342,   344,   346,
  249.    348,   350,   355,   359,   364,   367,   370,   372,   383,   396,
  250.    398,   400,   402,   404,   409,   411,   416,   421,   428,   430,
  251.    434,   435,   439,   441,   446,   448,   450,   452,   457,   459,
  252.    464,   466,   468,   470,   472,   478,   480,   485,   487,   492,
  253.    494,   500,   502,   504,   506,   511,   513,   518,   520,   526,
  254.    528,   530,   532,   537,   540,   545,   547,   552,   558,   560,
  255.    562,   568,   570,   578,   580,   586,   588,   590,   592,   594,
  256.    599,   602,   603,   605,   607,   613,   615,   617,   619,   621,
  257.    623,   625,   627,   632,   633,   635,   637,   639,   641,   643,
  258.    645,   650,   652,   654,   659,   661,   663,   671,   675,   677,
  259.    679,   681,   684,   691,   696,   698,   700,   704,   706,   711,
  260.    713,   721,   723,   728,   732,   736,   740,   741,   745,   748
  261. };
  262.  
  263. static const char * const yytname[] = {   "$","error","$illegal.","FUNC_CALL",
  264. "NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
  265. "NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
  266. "LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
  267. "LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_IN","LEX_AND",
  268. "LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'","'<'",
  269. "'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY","'^'","'$'","'('","')'",
  270. "'['","']'","'{'","'}'","';'","','","start","program","rule","@1","@2","func_name",
  271. "lex_builtin","function_prologue","@3","function_body","pattern","regexp","@4",
  272. "action","statements","statement_term","statement","@5","print","if_statement",
  273. "nls","opt_nls","input_redir","output_redir","opt_param_list","param_list","opt_exp",
  274. "opt_rexpression_list","rexpression_list","opt_expression_list","expression_list",
  275. "exp","@6","rexp","@7","simp_exp","non_post_simp_exp","@8","post_inc_dec_exp",
  276. "opt_variable","variable","l_brace","r_brace","r_paren","opt_semi","semi","comma",
  277. ""
  278. };
  279. #endif
  280.  
  281. static const short yyr1[] = {     0,
  282.     61,    62,    62,    62,    62,    64,    63,    65,    63,    63,
  283.     63,    63,    63,    63,    63,    66,    66,    66,    67,    67,
  284.     69,    68,    70,    71,    71,    73,    72,    74,    74,    75,
  285.     75,    75,    75,    76,    76,    77,    77,    77,    77,    77,
  286.     77,    77,    77,    77,    77,    77,    77,    77,    77,    77,
  287.     78,    77,    77,    77,    79,    79,    80,    80,    81,    81,
  288.     82,    82,    83,    83,    84,    84,    84,    84,    85,    85,
  289.     86,    86,    86,    86,    86,    87,    87,    88,    88,    89,
  290.     89,    89,    89,    89,    89,    90,    90,    91,    91,    91,
  291.     91,    91,    91,    93,    92,    92,    92,    92,    92,    92,
  292.     92,    92,    92,    92,    92,    92,    92,    92,    92,    92,
  293.     95,    94,    94,    94,    94,    94,    94,    94,    94,    94,
  294.     94,    94,    94,    96,    96,    96,    96,    96,    96,    96,
  295.     96,    97,    97,    98,    97,    97,    97,    97,    97,    97,
  296.     97,    97,    97,    97,    99,    99,    99,   100,   100,   101,
  297.    101,   101,   101,   102,   103,   104,   105,   105,   106,   107
  298. };
  299.  
  300. static const short yyr2[] = {     0,
  301.      3,     1,     2,     1,     2,     0,     3,     0,     3,     2,
  302.      2,     2,     1,     2,     2,     1,     1,     1,     1,     1,
  303.      0,     7,     4,     1,     3,     0,     4,     5,     4,     1,
  304.      2,     1,     2,     1,     2,     2,     2,     3,     1,     6,
  305.      8,     8,    10,     9,     2,     2,     6,     4,     3,     3,
  306.      0,     4,     6,     2,     1,     1,     6,     9,     1,     2,
  307.      0,     1,     0,     2,     0,     2,     2,     2,     0,     1,
  308.      1,     3,     1,     2,     3,     0,     1,     0,     1,     1,
  309.      3,     1,     2,     3,     3,     0,     1,     1,     3,     1,
  310.      2,     3,     3,     0,     4,     5,     4,     3,     3,     3,
  311.      3,     1,     2,     3,     3,     3,     3,     5,     1,     2,
  312.      0,     4,     3,     3,     3,     1,     2,     3,     3,     3,
  313.      5,     1,     2,     1,     1,     3,     3,     3,     3,     3,
  314.      3,     2,     3,     0,     5,     4,     1,     4,     2,     2,
  315.      1,     1,     2,     2,     2,     2,     1,     0,     1,     1,
  316.      4,     2,     2,     2,     2,     1,     0,     1,     1,     2
  317. };
  318.  
  319. static const short yydefact[] = {    61,
  320.     59,    62,     0,    60,     4,     0,   150,   141,   142,     6,
  321.      8,    21,   148,     0,     0,   134,   137,     0,     0,    26,
  322.      0,     0,     0,    61,     0,     2,     0,     0,   102,    13,
  323.     24,   109,   124,   125,   147,     0,     0,     0,   159,     0,
  324.     10,    34,    61,     0,    11,     0,    63,   149,   139,   140,
  325.      0,     0,     0,     0,   144,   147,   143,     0,   103,   132,
  326.    152,   153,    90,     0,    88,   154,     5,     3,     1,    15,
  327.      0,    12,    14,     0,     0,     0,     0,     0,     0,     0,
  328.      0,     0,    61,   110,     0,     0,     0,     0,     0,     0,
  329.      0,    94,   145,   146,    32,     0,    51,     0,     0,    61,
  330.      0,     0,     0,    55,    56,    76,    76,    61,     0,    30,
  331.      0,    39,     0,     0,   157,    61,     0,     0,    88,     0,
  332.      7,    35,     9,    17,    16,    19,    20,     0,    18,     0,
  333.     98,     0,     0,     0,     0,    91,   156,     0,     0,   133,
  334.      0,   105,   101,   104,    99,   100,     0,   106,   107,   148,
  335.    160,    25,   130,   131,   127,   128,   129,   126,     0,     0,
  336.     76,     0,     0,     0,    76,    45,    46,     0,    77,     0,
  337.    155,    33,    31,   157,    82,   148,     0,     0,   116,    65,
  338.      0,    80,   122,   147,    54,     0,    37,    61,   158,    36,
  339.    138,   151,     0,    64,     0,   136,    27,    92,     0,    93,
  340.     89,   157,     0,    97,    95,     0,     0,     0,     0,     0,
  341.    150,     0,    49,    50,    61,    63,   117,     0,     0,     0,
  342.      0,     0,    83,     0,     0,     0,     0,     0,     0,     0,
  343.    123,   111,    38,    29,    73,    71,     0,     0,   135,    96,
  344.     23,   108,    61,    52,     0,    61,     0,     0,     0,    28,
  345.    115,    65,    67,    66,    68,    48,    84,    85,    81,   120,
  346.    118,   119,   113,   114,     0,     0,    61,    74,     0,     0,
  347.      0,     0,     0,     0,     0,    76,     0,     0,   112,    22,
  348.     75,    72,    57,    53,    40,     0,    61,    76,     0,    47,
  349.    121,    61,    61,     0,     0,    61,     0,    41,    42,    61,
  350.      0,    58,     0,    44,    43,     0,     0,     0
  351. };
  352.  
  353. static const short yydefgoto[] = {   306,
  354.     25,    26,    40,    44,   128,   129,    27,    46,    70,    28,
  355.     29,    58,    30,   109,    41,   110,   161,   111,   112,     2,
  356.      3,   131,   222,   237,   238,   168,   180,   181,   117,   118,
  357.     84,   159,   231,   266,    32,    33,    51,    34,    47,    35,
  358.    114,   115,   140,   188,   116,   139
  359. };
  360.  
  361. static const short yypact[] = {    15,
  362. -32768,    19,   995,-32768,-32768,   -24,   -25,-32768,-32768,    -2,
  363.     -2,-32768,     6,     6,     6,-32768,   -16,   393,   393,-32768,
  364.   1713,   393,  1087,    15,   791,-32768,   -12,    -7,-32768,-32768,
  365.    737,   189,-32768,-32768,   106,   521,  1067,  1087,-32768,   -12,
  366. -32768,    19,    15,   -12,-32768,   110,    -1,-32768,-32768,-32768,
  367.     -5,  1067,   393,  1600,    11,   -11,    11,    62,-32768,    11,
  368. -32768,-32768,-32768,    25,  1200,-32768,-32768,-32768,-32768,-32768,
  369.    627,-32768,-32768,  1600,  1600,    65,  1600,  1600,  1600,  1600,
  370.   1600,    42,    15,   914,  1600,   393,   393,   393,   393,   393,
  371.    393,-32768,-32768,-32768,-32768,    37,-32768,   114,    54,    15,
  372.     57,    -2,    -2,-32768,-32768,  1600,  1600,    15,   580,-32768,
  373.    684,-32768,   895,   521,    60,    15,    70,    26,  1299,    38,
  374. -32768,-32768,-32768,-32768,-32768,-32768,-32768,    63,-32768,   393,
  375. -32768,  1067,    70,  1200,    79,  1600,-32768,    95,  1134,-32768,
  376.    580,  1775,  1728,-32768,  1440,  1346,  1252,  1775,  1775,     6,
  377. -32768,  1299,   103,   103,    11,    11,    11,    11,  1600,  1600,
  378.   1600,    73,  1600,   838,  1647,-32768,-32768,    -2,  1299,    -2,
  379. -32768,-32768,-32768,    60,-32768,     6,  1713,  1087,-32768,    92,
  380.      4,  1487,   189,   109,-32768,   580,-32768,    15,-32768,-32768,
  381. -32768,-32768,    12,   189,    70,-32768,-32768,  1299,   126,-32768,
  382.   1299,    60,  1600,-32768,  1299,  1200,    -2,  1087,  1200,   116,
  383.    -17,    60,-32768,-32768,    15,    -1,-32768,    25,  1600,  1600,
  384.   1600,    -2,  1666,  1153,  1666,  1666,   135,  1666,  1666,  1666,
  385.    969,-32768,-32768,-32768,-32768,-32768,    70,    41,-32768,-32768,
  386. -32768,  1299,    15,-32768,    52,    15,   100,   155,  1020,-32768,
  387. -32768,    92,  1299,  1299,  1299,-32768,  1487,-32768,  1487,   703,
  388.   1790,-32768,  1581,  1534,  1393,  1666,    15,-32768,    17,   838,
  389.     -2,   838,  1600,    70,   948,  1600,    -2,  1666,  1487,-32768,
  390. -32768,-32768,   152,-32768,-32768,  1200,    15,  1600,    70,-32768,
  391.   1487,    15,    15,   838,    70,    15,   838,-32768,-32768,    15,
  392.    838,-32768,   838,-32768,-32768,   171,   177,-32768
  393. };
  394.  
  395. static const short yypgoto[] = {-32768,
  396. -32768,   153,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  397.    229,-32768,    81,   -59,   305,   101,-32768,-32768,-32768,    77,
  398.    148,   -35,   -70,-32768,-32768,  -100,-32768,-32768,   -49,   -15,
  399.     -3,-32768,   -27,-32768,   240,   162,-32768,-32768,   -61,    78,
  400.     16,  -105,   -63,  -143,   112,   -29
  401. };
  402.  
  403.  
  404. #define    YYLAST        1843
  405.  
  406.  
  407. static const short yytable[] = {    31,
  408.    138,    85,   133,   174,   223,     1,   170,    64,   187,     7,
  409.      1,   141,   235,   -79,   248,   236,   -79,   281,    36,    65,
  410.    282,    31,   120,    93,    94,   136,   136,     1,    37,    38,
  411.    215,     4,   113,   119,   119,   202,    52,    38,   136,   130,
  412.     36,   268,    71,    36,    24,   -79,   -79,   132,   119,    24,
  413.    134,    39,   136,   191,   186,    36,    39,    22,   241,    36,
  414.    207,    91,   -79,    83,   212,   -69,   135,   113,   144,   196,
  415.    142,   143,   150,   145,   146,   147,   148,   149,   137,   -87,
  416.    233,   152,   195,   182,    83,    83,    42,    42,   204,   160,
  417.     48,    49,    50,   192,   -70,    56,    56,    83,    56,    62,
  418.     83,   219,   169,   169,    42,   113,   163,   271,    72,   165,
  419.    113,    83,   124,   125,   216,   193,    92,   162,    39,   232,
  420.    121,    43,    43,   137,   123,   197,   199,   208,   119,   240,
  421.     56,   239,   198,   220,   221,   201,   247,   113,   262,    43,
  422.     93,    94,   243,    93,    94,   246,   126,   127,    88,    89,
  423.     90,   224,   273,    91,   252,   205,   206,   169,   274,   209,
  424.    113,   169,   218,    56,    56,    56,    56,    56,    56,   292,
  425.    307,    66,    69,   267,    65,   289,   308,    68,    42,    42,
  426.    251,   277,   113,    61,     0,     0,     0,   295,   184,    42,
  427.    122,     0,   245,     0,     0,   257,   259,   260,   261,   242,
  428.    263,   264,   265,     0,   119,     0,     0,    56,   269,   173,
  429.    287,     0,     0,    43,    43,   253,   254,   255,     0,     0,
  430.      0,     0,   293,     0,    43,   296,   189,    48,     0,     0,
  431.    151,   300,    86,    87,    88,    89,    90,     0,   279,    91,
  432.      0,   173,     0,     0,    42,   275,    42,   164,     0,    59,
  433.    291,     0,     0,    48,    56,   171,     0,    55,    57,   184,
  434.     60,     0,     0,   190,   210,     0,   113,     0,   113,   286,
  435.      0,     0,   169,     0,     0,     0,     0,     0,     0,    43,
  436.      0,    43,     0,    42,   169,   189,   173,     0,     0,     0,
  437.    113,     0,    60,   113,     0,     0,     0,   113,    42,   113,
  438.    184,   184,   184,   184,     0,   184,   184,   184,   184,     0,
  439.      0,     0,     0,   189,     0,    45,     0,     0,    43,     0,
  440.      0,     0,     0,   249,     0,   153,   154,   155,   156,   157,
  441.    158,     0,    73,    43,   184,   234,   184,   184,   184,   179,
  442.    184,   184,   184,   184,     0,     0,     0,    42,     0,     0,
  443.    183,     0,     0,    42,     0,   184,   184,     0,     0,     0,
  444.    276,     0,   250,     0,     0,     0,     0,     0,   184,   194,
  445.    283,     0,   285,     0,     0,     0,     0,     0,     0,     0,
  446.      0,     0,    43,     0,     0,     0,   288,     0,    43,     0,
  447.    270,     0,     0,   272,   299,     6,     7,   302,     0,     8,
  448.      9,   304,     0,   305,     0,   217,   166,   167,     0,     0,
  449.    179,     0,     0,     0,   280,     0,    60,   185,     0,     0,
  450.      0,   183,     0,     0,     0,     0,     0,    14,    15,    16,
  451.     17,     0,     0,     0,   294,     0,    18,    19,     0,   297,
  452.    298,    53,     0,   301,    22,    54,     0,   303,     0,     0,
  453.      0,   179,   179,   179,   179,     0,   179,   179,   179,   179,
  454.      0,     0,   183,   183,   183,   183,     0,   183,   183,   183,
  455.    183,     0,   213,     0,   214,     0,     0,     0,     0,     0,
  456.      0,     0,     0,     0,     0,   179,     0,   179,   179,   179,
  457.      0,   179,   179,   179,   179,     0,   183,     0,   183,   183,
  458.    183,     0,   183,   183,   183,   183,   179,   179,     0,     0,
  459.      0,   244,     0,     0,     0,     0,     0,   183,   183,   179,
  460.      0,    95,     0,     6,     7,     0,   256,     8,     9,     0,
  461.    183,     0,     0,     0,     0,     0,     0,    96,     0,    97,
  462.     98,    99,   100,   101,   102,   103,   104,   105,   106,   107,
  463.      0,    13,     0,     0,     0,    14,    15,    16,    17,     0,
  464.      0,     0,     0,     0,    18,    19,     0,    20,     0,    21,
  465.      0,     0,    22,    23,     0,   284,     0,    24,   108,    39,
  466.    172,   290,     6,     7,     0,     0,     8,     9,     0,     0,
  467.      0,     0,     0,     0,     0,     0,    96,     0,    97,    98,
  468.     99,   100,   101,   102,   103,   104,   105,   106,   107,     0,
  469.     13,     0,     0,     0,    14,    15,    16,    17,     0,     0,
  470.      0,     0,     0,    18,    19,     0,    20,    95,    21,     6,
  471.      7,    22,    23,     8,     9,     0,    24,   108,    39,     0,
  472.      0,     0,     0,    96,     0,    97,    98,    99,   100,   101,
  473.    102,   103,   104,   105,   106,   107,     0,    13,     0,     0,
  474.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  475.     18,    19,     0,    20,     0,    21,     0,     0,    22,    23,
  476.      0,     0,     0,    24,   175,    39,     6,     7,     0,     0,
  477.      8,     9,     0,   -78,     0,     0,   -78,     0,     0,     0,
  478.      0,     0,     0,     0,     0,     0,     7,     0,     0,     8,
  479.      9,-32768,     0,     0,   176,     0,     0,     0,    14,    15,
  480.     16,    17,     0,     0,     0,   -78,   -78,    18,    19,     0,
  481.     20,     0,   177,     0,     0,    22,   178,    14,    15,     6,
  482.      7,     0,   -78,     8,     9,    74,    18,    19,    75,    20,
  483.      0,   177,     0,     0,    22,    54,     0,     0,     0,     0,
  484.      0,     0,     0,     0,     0,     0,     0,    13,    76,    77,
  485.     78,    14,    15,    16,    17,    79,     0,    80,    81,    82,
  486.     18,    19,     0,    20,     0,    21,     0,     0,    22,    23,
  487.    -61,    67,     0,     6,     7,     0,    83,     8,     9,     0,
  488.      0,     0,     0,     1,     0,    10,    11,     0,     0,     0,
  489.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  490.     12,    13,     0,     0,     0,    14,    15,    16,    17,     0,
  491.      0,     0,     0,     0,    18,    19,     0,    20,     0,    21,
  492.      6,     7,    22,    23,     8,     9,     0,    24,     0,     0,
  493.      0,     0,     0,     0,    96,     0,    97,    98,    99,   100,
  494.    101,   102,   103,   104,   105,   106,   107,     0,    13,     0,
  495.      0,     0,    14,    15,    16,    17,     0,     0,     0,     0,
  496.      0,    18,    19,     0,    20,     0,    21,     0,     0,    22,
  497.     23,     0,     0,     0,    24,     0,    39,     6,     7,     0,
  498.      0,     8,     9,    74,     0,     0,    75,     1,     0,     0,
  499.      0,     0,     0,     0,     0,     0,     0,     7,     0,     0,
  500.      8,     9,     0,     0,     0,    13,    76,    77,    78,    14,
  501.     15,    16,    17,    79,     0,    80,    81,    82,    18,    19,
  502.      0,    20,     0,    21,     0,     0,    22,    23,    14,    15,
  503.      6,     7,     0,    39,     8,     9,    74,    18,    19,    75,
  504.     20,     0,    21,     0,     0,    22,    23,     0,     0,     0,
  505.      0,     0,     7,     0,     0,     8,     9,     0,    13,    76,
  506.     77,    78,    14,    15,    16,    17,    79,     0,    80,    81,
  507.     82,    18,    19,     0,    20,     5,    21,     6,     7,    22,
  508.     23,     8,     9,    14,    15,     0,    39,     0,     0,    10,
  509.     11,     0,    18,    19,     0,    20,     0,   177,     0,     0,
  510.     22,    54,     6,     7,    12,    13,     8,     9,     0,    14,
  511.     15,    16,    17,     0,     0,     0,     0,     0,    18,    19,
  512.      0,    20,     0,    21,     0,     0,    22,    23,     0,     0,
  513.     13,    24,     0,     0,    14,    15,    16,    17,     0,     0,
  514.      0,     0,     0,    18,    19,     0,    20,    63,    21,     6,
  515.      7,    22,    23,     8,     9,     0,     0,     0,    39,     0,
  516.      0,     0,     0,     0,     0,     0,     0,    63,     0,     6,
  517.      7,     0,     0,     8,     9,     0,     0,    13,     0,     0,
  518.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  519.     18,    19,     0,    20,     0,    21,     0,    13,    22,    23,
  520.    -86,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  521.     18,    19,     0,    20,   200,    21,     6,     7,    22,    23,
  522.      8,     9,     0,     0,     0,     0,     0,     0,     0,     0,
  523.      0,     0,     0,   258,     0,     6,     7,     0,     0,     8,
  524.      9,     0,     0,     0,    13,     0,     0,     0,    14,    15,
  525.     16,    17,     0,     0,     0,     0,     0,    18,    19,     0,
  526.     20,     0,    21,   176,     0,    22,    23,    14,    15,    16,
  527.     17,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  528.      0,   177,     6,     7,    22,    54,     8,     9,    74,     0,
  529.      0,    75,     0,     0,     0,     0,     0,     0,     0,     0,
  530.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  531.     13,    76,    77,    78,    14,    15,    16,    17,    79,     0,
  532.     80,    81,    82,    18,    19,     0,    20,     0,    21,     0,
  533.      0,    22,    23,   137,     6,     7,     0,     0,     8,     9,
  534.     74,     0,     0,    75,     0,     0,     0,     0,     0,     0,
  535.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  536.      0,     0,    13,    76,    77,    78,    14,    15,    16,    17,
  537.     79,   203,    80,    81,    82,    18,    19,     0,    20,     0,
  538.     21,     6,     7,    22,    23,     8,     9,    74,     0,     0,
  539.     75,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  540.      0,     0,     0,     0,     0,     0,     0,     0,     0,    13,
  541.     76,    77,    78,    14,    15,    16,    17,    79,     0,    80,
  542.     81,    82,    18,    19,     0,    20,     0,    21,     6,     7,
  543.     22,    23,     8,     9,    74,     0,     0,    75,     0,     0,
  544.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  545.      0,     0,     0,     0,     0,     0,    13,    76,    77,     0,
  546.     14,    15,    16,    17,     0,     0,    80,    81,    82,    18,
  547.     19,     0,    20,     0,    21,     6,     7,    22,    23,     8,
  548.      9,   225,     0,     0,   226,     0,     0,     0,     0,     0,
  549.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  550.      0,     0,     0,   176,   227,   228,   229,    14,    15,    16,
  551.     17,   230,   278,     0,     0,     0,    18,    19,     0,    20,
  552.      0,   177,     6,     7,    22,    54,     8,     9,    74,     0,
  553.      0,    75,     0,     0,     0,     0,     0,     0,     0,     0,
  554.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  555.     13,    76,     0,     0,    14,    15,    16,    17,     0,     0,
  556.     80,    81,    82,    18,    19,     0,    20,     0,    21,     6,
  557.      7,    22,    23,     8,     9,   225,     0,     0,   226,     0,
  558.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  559.      0,     0,     0,     0,     0,     0,     0,   176,   227,   228,
  560.    229,    14,    15,    16,    17,   230,     0,     0,     0,     0,
  561.     18,    19,     0,    20,     0,   177,     6,     7,    22,    54,
  562.      8,     9,   225,     0,     0,   226,     0,     0,     0,     0,
  563.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  564.      0,     0,     0,     0,   176,   227,   228,     0,    14,    15,
  565.     16,    17,     0,     0,     0,     0,     0,    18,    19,     0,
  566.     20,     0,   177,     6,     7,    22,    54,     8,     9,   225,
  567.      0,     0,   226,     0,     0,     0,     0,     0,     0,     0,
  568.      0,     0,     6,     7,     0,     0,     8,     9,     0,     0,
  569.      0,   176,   227,     0,     0,    14,    15,    16,    17,     0,
  570.      0,     0,     0,     0,    18,    19,     0,    20,     0,   177,
  571.     13,     0,    22,    54,    14,    15,    16,    17,     0,     0,
  572.      0,     0,     0,    18,    19,     0,    20,     0,    21,     6,
  573.    211,    22,    23,     8,     9,     0,     0,     0,     0,     0,
  574.      0,     0,     0,     0,     0,     0,     0,     0,     6,     7,
  575.      0,     0,     8,     9,     0,     0,     0,    13,     0,     0,
  576.      0,    14,    15,    16,    17,     0,     0,     0,     0,     0,
  577.     18,    19,     0,    20,     0,    21,   176,     0,    22,    23,
  578.     14,    15,    16,    17,     0,     0,     0,     0,     0,    18,
  579.     19,     0,    20,     0,   177,     6,     7,    22,    54,     8,
  580.      9,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  581.      0,     7,     0,     0,     8,     9,    74,     0,     0,-32768,
  582.      0,     0,     0,     0,     0,     0,     0,    14,    15,    16,
  583.     17,     0,     0,     0,     0,     0,    18,    19,     0,    20,
  584.      0,    53,    14,    15,    22,    54,     0,     0,    80,    81,
  585.     82,    18,    19,     0,    20,     0,    21,     0,     7,    22,
  586.     23,     8,     9,-32768,     0,     0,     0,     0,     0,     0,
  587.      0,     0,     0,     7,     0,     0,     8,     9,   225,     0,
  588.      0,-32768,     0,     0,     0,     0,     0,     0,     0,    14,
  589.     15,     0,     0,     0,     0,-32768,-32768,-32768,    18,    19,
  590.      0,    20,     0,    21,    14,    15,    22,    23,     0,     0,
  591.      0,     0,     0,    18,    19,     0,    20,     0,   177,     0,
  592.      0,    22,    54
  593. };
  594.  
  595. static const short yycheck[] = {     3,
  596.     64,    31,    52,   109,     1,    13,   107,    23,   114,     4,
  597.     13,    71,     1,    10,    32,     4,    13,     1,     3,    23,
  598.      4,    25,    38,    35,    36,     1,     1,    13,    53,    55,
  599.    174,    13,    36,    37,    38,   141,    53,    55,     1,    41,
  600.     25,     1,    27,    28,    57,    42,    43,    53,    52,    57,
  601.     54,    59,     1,   117,   114,    40,    59,    52,   202,    44,
  602.    161,    51,    59,    60,   165,    54,     5,    71,     4,   133,
  603.     74,    75,    31,    77,    78,    79,    80,    81,    54,    54,
  604.    186,    85,   132,   111,    60,    60,    10,    11,   150,    53,
  605.     13,    14,    15,    56,    54,    18,    19,    60,    21,    22,
  606.     60,    10,   106,   107,    28,   109,    53,    56,    28,    53,
  607.    114,    60,     3,     4,   176,    53,    11,     4,    59,    11,
  608.     40,    10,    11,    54,    44,    47,    32,    55,   132,     4,
  609.     53,   195,   136,    42,    43,   139,    21,   141,     4,    28,
  610.     35,    36,   206,    35,    36,   209,    37,    38,    46,    47,
  611.     48,   181,    53,    51,   218,   159,   160,   161,     4,   163,
  612.    164,   165,   178,    86,    87,    88,    89,    90,    91,    18,
  613.      0,    24,    25,   237,   178,   276,     0,    25,   102,   103,
  614.    216,   252,   186,    22,    -1,    -1,    -1,   288,   111,   113,
  615.     43,    -1,   208,    -1,    -1,   223,   224,   225,   226,   203,
  616.    228,   229,   230,    -1,   208,    -1,    -1,   130,   238,   109,
  617.    274,    -1,    -1,   102,   103,   219,   220,   221,    -1,    -1,
  618.     -1,    -1,   286,    -1,   113,   289,   115,   150,    -1,    -1,
  619.     83,   295,    44,    45,    46,    47,    48,    -1,   266,    51,
  620.     -1,   141,    -1,    -1,   168,   249,   170,   100,    -1,    21,
  621.    278,    -1,    -1,   176,   177,   108,    -1,    18,    19,   182,
  622.     21,    -1,    -1,   116,   164,    -1,   270,    -1,   272,   273,
  623.     -1,    -1,   276,    -1,    -1,    -1,    -1,    -1,    -1,   168,
  624.     -1,   170,    -1,   207,   288,   174,   186,    -1,    -1,    -1,
  625.    294,    -1,    53,   297,    -1,    -1,    -1,   301,   222,   303,
  626.    223,   224,   225,   226,    -1,   228,   229,   230,   231,    -1,
  627.     -1,    -1,    -1,   202,    -1,    11,    -1,    -1,   207,    -1,
  628.     -1,    -1,    -1,   212,    -1,    86,    87,    88,    89,    90,
  629.     91,    -1,    28,   222,   257,   188,   259,   260,   261,   111,
  630.    263,   264,   265,   266,    -1,    -1,    -1,   271,    -1,    -1,
  631.    111,    -1,    -1,   277,    -1,   278,   279,    -1,    -1,    -1,
  632.    249,    -1,   215,    -1,    -1,    -1,    -1,    -1,   291,   130,
  633.    270,    -1,   272,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  634.     -1,    -1,   271,    -1,    -1,    -1,   275,    -1,   277,    -1,
  635.    243,    -1,    -1,   246,   294,     3,     4,   297,    -1,     7,
  636.      8,   301,    -1,   303,    -1,   177,   102,   103,    -1,    -1,
  637.    182,    -1,    -1,    -1,   267,    -1,   177,   113,    -1,    -1,
  638.     -1,   182,    -1,    -1,    -1,    -1,    -1,    35,    36,    37,
  639.     38,    -1,    -1,    -1,   287,    -1,    44,    45,    -1,   292,
  640.    293,    49,    -1,   296,    52,    53,    -1,   300,    -1,    -1,
  641.     -1,   223,   224,   225,   226,    -1,   228,   229,   230,   231,
  642.     -1,    -1,   223,   224,   225,   226,    -1,   228,   229,   230,
  643.    231,    -1,   168,    -1,   170,    -1,    -1,    -1,    -1,    -1,
  644.     -1,    -1,    -1,    -1,    -1,   257,    -1,   259,   260,   261,
  645.     -1,   263,   264,   265,   266,    -1,   257,    -1,   259,   260,
  646.    261,    -1,   263,   264,   265,   266,   278,   279,    -1,    -1,
  647.     -1,   207,    -1,    -1,    -1,    -1,    -1,   278,   279,   291,
  648.     -1,     1,    -1,     3,     4,    -1,   222,     7,     8,    -1,
  649.    291,    -1,    -1,    -1,    -1,    -1,    -1,    17,    -1,    19,
  650.     20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  651.     -1,    31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,
  652.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  653.     -1,    -1,    52,    53,    -1,   271,    -1,    57,    58,    59,
  654.      1,   277,     3,     4,    -1,    -1,     7,     8,    -1,    -1,
  655.     -1,    -1,    -1,    -1,    -1,    -1,    17,    -1,    19,    20,
  656.     21,    22,    23,    24,    25,    26,    27,    28,    29,    -1,
  657.     31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  658.     -1,    -1,    -1,    44,    45,    -1,    47,     1,    49,     3,
  659.      4,    52,    53,     7,     8,    -1,    57,    58,    59,    -1,
  660.     -1,    -1,    -1,    17,    -1,    19,    20,    21,    22,    23,
  661.     24,    25,    26,    27,    28,    29,    -1,    31,    -1,    -1,
  662.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  663.     44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,    53,
  664.     -1,    -1,    -1,    57,     1,    59,     3,     4,    -1,    -1,
  665.      7,     8,    -1,    10,    -1,    -1,    13,    -1,    -1,    -1,
  666.     -1,    -1,    -1,    -1,    -1,    -1,     4,    -1,    -1,     7,
  667.      8,     9,    -1,    -1,    31,    -1,    -1,    -1,    35,    36,
  668.     37,    38,    -1,    -1,    -1,    42,    43,    44,    45,    -1,
  669.     47,    -1,    49,    -1,    -1,    52,    53,    35,    36,     3,
  670.      4,    -1,    59,     7,     8,     9,    44,    45,    12,    47,
  671.     -1,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,    -1,
  672.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
  673.     34,    35,    36,    37,    38,    39,    -1,    41,    42,    43,
  674.     44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,    53,
  675.      0,     1,    -1,     3,     4,    -1,    60,     7,     8,    -1,
  676.     -1,    -1,    -1,    13,    -1,    15,    16,    -1,    -1,    -1,
  677.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  678.     30,    31,    -1,    -1,    -1,    35,    36,    37,    38,    -1,
  679.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  680.      3,     4,    52,    53,     7,     8,    -1,    57,    -1,    -1,
  681.     -1,    -1,    -1,    -1,    17,    -1,    19,    20,    21,    22,
  682.     23,    24,    25,    26,    27,    28,    29,    -1,    31,    -1,
  683.     -1,    -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,
  684.     -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,    52,
  685.     53,    -1,    -1,    -1,    57,    -1,    59,     3,     4,    -1,
  686.     -1,     7,     8,     9,    -1,    -1,    12,    13,    -1,    -1,
  687.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     4,    -1,    -1,
  688.      7,     8,    -1,    -1,    -1,    31,    32,    33,    34,    35,
  689.     36,    37,    38,    39,    -1,    41,    42,    43,    44,    45,
  690.     -1,    47,    -1,    49,    -1,    -1,    52,    53,    35,    36,
  691.      3,     4,    -1,    59,     7,     8,     9,    44,    45,    12,
  692.     47,    -1,    49,    -1,    -1,    52,    53,    -1,    -1,    -1,
  693.     -1,    -1,     4,    -1,    -1,     7,     8,    -1,    31,    32,
  694.     33,    34,    35,    36,    37,    38,    39,    -1,    41,    42,
  695.     43,    44,    45,    -1,    47,     1,    49,     3,     4,    52,
  696.     53,     7,     8,    35,    36,    -1,    59,    -1,    -1,    15,
  697.     16,    -1,    44,    45,    -1,    47,    -1,    49,    -1,    -1,
  698.     52,    53,     3,     4,    30,    31,     7,     8,    -1,    35,
  699.     36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,
  700.     -1,    47,    -1,    49,    -1,    -1,    52,    53,    -1,    -1,
  701.     31,    57,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  702.     -1,    -1,    -1,    44,    45,    -1,    47,     1,    49,     3,
  703.      4,    52,    53,     7,     8,    -1,    -1,    -1,    59,    -1,
  704.     -1,    -1,    -1,    -1,    -1,    -1,    -1,     1,    -1,     3,
  705.      4,    -1,    -1,     7,     8,    -1,    -1,    31,    -1,    -1,
  706.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  707.     44,    45,    -1,    47,    -1,    49,    -1,    31,    52,    53,
  708.     54,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  709.     44,    45,    -1,    47,     1,    49,     3,     4,    52,    53,
  710.      7,     8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  711.     -1,    -1,    -1,     1,    -1,     3,     4,    -1,    -1,     7,
  712.      8,    -1,    -1,    -1,    31,    -1,    -1,    -1,    35,    36,
  713.     37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,
  714.     47,    -1,    49,    31,    -1,    52,    53,    35,    36,    37,
  715.     38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,
  716.     -1,    49,     3,     4,    52,    53,     7,     8,     9,    -1,
  717.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  718.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  719.     31,    32,    33,    34,    35,    36,    37,    38,    39,    -1,
  720.     41,    42,    43,    44,    45,    -1,    47,    -1,    49,    -1,
  721.     -1,    52,    53,    54,     3,     4,    -1,    -1,     7,     8,
  722.      9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,
  723.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  724.     -1,    -1,    31,    32,    33,    34,    35,    36,    37,    38,
  725.     39,    40,    41,    42,    43,    44,    45,    -1,    47,    -1,
  726.     49,     3,     4,    52,    53,     7,     8,     9,    -1,    -1,
  727.     12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  728.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,
  729.     32,    33,    34,    35,    36,    37,    38,    39,    -1,    41,
  730.     42,    43,    44,    45,    -1,    47,    -1,    49,     3,     4,
  731.     52,    53,     7,     8,     9,    -1,    -1,    12,    -1,    -1,
  732.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  733.     -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,    -1,
  734.     35,    36,    37,    38,    -1,    -1,    41,    42,    43,    44,
  735.     45,    -1,    47,    -1,    49,     3,     4,    52,    53,     7,
  736.      8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,
  737.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  738.     -1,    -1,    -1,    31,    32,    33,    34,    35,    36,    37,
  739.     38,    39,    40,    -1,    -1,    -1,    44,    45,    -1,    47,
  740.     -1,    49,     3,     4,    52,    53,     7,     8,     9,    -1,
  741.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  742.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  743.     31,    32,    -1,    -1,    35,    36,    37,    38,    -1,    -1,
  744.     41,    42,    43,    44,    45,    -1,    47,    -1,    49,     3,
  745.      4,    52,    53,     7,     8,     9,    -1,    -1,    12,    -1,
  746.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  747.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
  748.     34,    35,    36,    37,    38,    39,    -1,    -1,    -1,    -1,
  749.     44,    45,    -1,    47,    -1,    49,     3,     4,    52,    53,
  750.      7,     8,     9,    -1,    -1,    12,    -1,    -1,    -1,    -1,
  751.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  752.     -1,    -1,    -1,    -1,    31,    32,    33,    -1,    35,    36,
  753.     37,    38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,
  754.     47,    -1,    49,     3,     4,    52,    53,     7,     8,     9,
  755.     -1,    -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  756.     -1,    -1,     3,     4,    -1,    -1,     7,     8,    -1,    -1,
  757.     -1,    31,    32,    -1,    -1,    35,    36,    37,    38,    -1,
  758.     -1,    -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,
  759.     31,    -1,    52,    53,    35,    36,    37,    38,    -1,    -1,
  760.     -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,     3,
  761.      4,    52,    53,     7,     8,    -1,    -1,    -1,    -1,    -1,
  762.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     3,     4,
  763.     -1,    -1,     7,     8,    -1,    -1,    -1,    31,    -1,    -1,
  764.     -1,    35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,
  765.     44,    45,    -1,    47,    -1,    49,    31,    -1,    52,    53,
  766.     35,    36,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
  767.     45,    -1,    47,    -1,    49,     3,     4,    52,    53,     7,
  768.      8,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  769.     -1,     4,    -1,    -1,     7,     8,     9,    -1,    -1,    12,
  770.     -1,    -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    37,
  771.     38,    -1,    -1,    -1,    -1,    -1,    44,    45,    -1,    47,
  772.     -1,    49,    35,    36,    52,    53,    -1,    -1,    41,    42,
  773.     43,    44,    45,    -1,    47,    -1,    49,    -1,     4,    52,
  774.     53,     7,     8,     9,    -1,    -1,    -1,    -1,    -1,    -1,
  775.     -1,    -1,    -1,     4,    -1,    -1,     7,     8,     9,    -1,
  776.     -1,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    35,
  777.     36,    -1,    -1,    -1,    -1,    41,    42,    43,    44,    45,
  778.     -1,    47,    -1,    49,    35,    36,    52,    53,    -1,    -1,
  779.     -1,    -1,    -1,    44,    45,    -1,    47,    -1,    49,    -1,
  780.     -1,    52,    53
  781. };
  782. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  783. #line 3 "bison.simple"
  784.  
  785. /* Skeleton output parser for bison,
  786.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  787.  
  788.    This program is free software; you can redistribute it and/or modify
  789.    it under the terms of the GNU General Public License as published by
  790.    the Free Software Foundation; either version 1, or (at your option)
  791.    any later version.
  792.  
  793.    This program is distributed in the hope that it will be useful,
  794.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  795.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  796.    GNU General Public License for more details.
  797.  
  798.    You should have received a copy of the GNU General Public License
  799.    along with this program; if not, write to the Free Software
  800.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  801.  
  802.  
  803. #ifndef alloca
  804. #ifdef __GNUC__
  805. #define alloca __builtin_alloca
  806. #else /* not GNU C.  */
  807. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  808. #include <alloca.h>
  809. #else /* not sparc */
  810. #if defined (MSDOS) && !defined (__TURBOC__)
  811. #include <malloc.h>
  812. #else /* not MSDOS, or __TURBOC__ */
  813. #if defined(_AIX)
  814. #include <malloc.h>
  815.  #pragma alloca
  816. #endif /* not _AIX */
  817. #endif /* not MSDOS, or __TURBOC__ */
  818. #endif /* not sparc.  */
  819. #endif /* not GNU C.  */
  820. #endif /* alloca not defined.  */
  821.  
  822. /* This is the parser code that is written into each bison parser
  823.   when the %semantic_parser declaration is not specified in the grammar.
  824.   It was written by Richard Stallman by simplifying the hairy parser
  825.   used when %semantic_parser is specified.  */
  826.  
  827. /* Note: there must be only one dollar sign in this file.
  828.    It is replaced by the list of actions, each action
  829.    as one case of the switch.  */
  830.  
  831. #define yyerrok        (yyerrstatus = 0)
  832. #define yyclearin    (yychar = YYEMPTY)
  833. #define YYEMPTY        -2
  834. #define YYEOF        0
  835. #define YYACCEPT    return(0)
  836. #define YYABORT     return(1)
  837. #define YYERROR        goto yyerrlab1
  838. /* Like YYERROR except do call yyerror.
  839.    This remains here temporarily to ease the
  840.    transition to the new meaning of YYERROR, for GCC.
  841.    Once GCC version 2 has supplanted version 1, this can go.  */
  842. #define YYFAIL        goto yyerrlab
  843. #define YYRECOVERING()  (!!yyerrstatus)
  844. #define YYBACKUP(token, value) \
  845. do                                \
  846.   if (yychar == YYEMPTY && yylen == 1)                \
  847.     { yychar = (token), yylval = (value);            \
  848.       yychar1 = YYTRANSLATE (yychar);                \
  849.       YYPOPSTACK;                        \
  850.       goto yybackup;                        \
  851.     }                                \
  852.   else                                \
  853.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  854. while (0)
  855.  
  856. #define YYTERROR    1
  857. #define YYERRCODE    256
  858.  
  859. #ifndef YYPURE
  860. #define YYLEX        yylex()
  861. #endif
  862.  
  863. #ifdef YYPURE
  864. #ifdef YYLSP_NEEDED
  865. #define YYLEX        yylex(&yylval, &yylloc)
  866. #else
  867. #define YYLEX        yylex(&yylval)
  868. #endif
  869. #endif
  870.  
  871. /* If nonreentrant, generate the variables here */
  872.  
  873. #ifndef YYPURE
  874.  
  875. int    yychar;            /*  the lookahead symbol        */
  876. YYSTYPE    yylval;            /*  the semantic value of the        */
  877.                 /*  lookahead symbol            */
  878.  
  879. #ifdef YYLSP_NEEDED
  880. YYLTYPE yylloc;            /*  location data for the lookahead    */
  881.                 /*  symbol                */
  882. #endif
  883.  
  884. int yynerrs;            /*  number of parse errors so far       */
  885. #endif  /* not YYPURE */
  886.  
  887. #if YYDEBUG != 0
  888. int yydebug;            /*  nonzero means print parse trace    */
  889. /* Since this is uninitialized, it does not stop multiple parsers
  890.    from coexisting.  */
  891. #endif
  892.  
  893. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  894.  
  895. #ifndef    YYINITDEPTH
  896. #define YYINITDEPTH 200
  897. #endif
  898.  
  899. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  900.     (effective only if the built-in stack extension method is used).  */
  901.  
  902. #if YYMAXDEPTH == 0
  903. #undef YYMAXDEPTH
  904. #endif
  905.  
  906. #ifndef YYMAXDEPTH
  907. #define YYMAXDEPTH 10000
  908. #endif
  909.  
  910. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  911. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  912. #else                /* not GNU C or C++ */
  913. #ifndef __cplusplus
  914.  
  915. /* This is the most reliable way to avoid incompatibilities
  916.    in available built-in functions on various systems.  */
  917. static void
  918. __yy_bcopy (from, to, count)
  919.      char *from;
  920.      char *to;
  921.      int count;
  922. {
  923.   register char *f = from;
  924.   register char *t = to;
  925.   register int i = count;
  926.  
  927.   while (i-- > 0)
  928.     *t++ = *f++;
  929. }
  930.  
  931. #else /* __cplusplus */
  932.  
  933. /* This is the most reliable way to avoid incompatibilities
  934.    in available built-in functions on various systems.  */
  935. static void
  936. __yy_bcopy (char *from, char *to, int count)
  937. {
  938.   register char *f = from;
  939.   register char *t = to;
  940.   register int i = count;
  941.  
  942.   while (i-- > 0)
  943.     *t++ = *f++;
  944. }
  945.  
  946. #endif
  947. #endif
  948.  
  949. #line 169 "bison.simple"
  950. int
  951. yyparse()
  952. {
  953.   register int yystate;
  954.   register int yyn;
  955.   register short *yyssp;
  956.   register YYSTYPE *yyvsp;
  957.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  958.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  959.  
  960.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  961.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  962.  
  963.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  964.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  965.  
  966. #ifdef YYLSP_NEEDED
  967.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  968.   YYLTYPE *yyls = yylsa;
  969.   YYLTYPE *yylsp;
  970.  
  971. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  972. #else
  973. #define YYPOPSTACK   (yyvsp--, yysp--)
  974. #endif
  975.  
  976.   int yystacksize = YYINITDEPTH;
  977.  
  978. #ifdef YYPURE
  979.   int yychar;
  980.   YYSTYPE yylval;
  981.   int yynerrs;
  982. #ifdef YYLSP_NEEDED
  983.   YYLTYPE yylloc;
  984. #endif
  985. #endif
  986.  
  987.   YYSTYPE yyval;        /*  the variable used to return        */
  988.                 /*  semantic values from the action    */
  989.                 /*  routines                */
  990.  
  991.   int yylen;
  992.  
  993. #if YYDEBUG != 0
  994.   if (yydebug)
  995.     fprintf(stderr, "Starting parse\n");
  996. #endif
  997.  
  998.   yystate = 0;
  999.   yyerrstatus = 0;
  1000.   yynerrs = 0;
  1001.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  1002.  
  1003.   /* Initialize stack pointers.
  1004.      Waste one element of value and location stack
  1005.      so that they stay on the same level as the state stack.  */
  1006.  
  1007.   yyssp = yyss - 1;
  1008.   yyvsp = yyvs;
  1009. #ifdef YYLSP_NEEDED
  1010.   yylsp = yyls;
  1011. #endif
  1012.  
  1013. /* Push a new state, which is found in  yystate  .  */
  1014. /* In all cases, when you get here, the value and location stacks
  1015.    have just been pushed. so pushing a state here evens the stacks.  */
  1016. yynewstate:
  1017.  
  1018.   *++yyssp = yystate;
  1019.  
  1020.   if (yyssp >= yyss + yystacksize - 1)
  1021.     {
  1022.       /* Give user a chance to reallocate the stack */
  1023.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  1024.       YYSTYPE *yyvs1 = yyvs;
  1025.       short *yyss1 = yyss;
  1026. #ifdef YYLSP_NEEDED
  1027.       YYLTYPE *yyls1 = yyls;
  1028. #endif
  1029.  
  1030.       /* Get the current used size of the three stacks, in elements.  */
  1031.       int size = yyssp - yyss + 1;
  1032.  
  1033. #ifdef yyoverflow
  1034.       /* Each stack pointer address is followed by the size of
  1035.      the data in use in that stack, in bytes.  */
  1036.       yyoverflow("parser stack overflow",
  1037.          &yyss1, size * sizeof (*yyssp),
  1038.          &yyvs1, size * sizeof (*yyvsp),
  1039. #ifdef YYLSP_NEEDED
  1040.          &yyls1, size * sizeof (*yylsp),
  1041. #endif
  1042.          &yystacksize);
  1043.  
  1044.       yyss = yyss1; yyvs = yyvs1;
  1045. #ifdef YYLSP_NEEDED
  1046.       yyls = yyls1;
  1047. #endif
  1048. #else /* no yyoverflow */
  1049.       /* Extend the stack our own way.  */
  1050.       if (yystacksize >= YYMAXDEPTH)
  1051.     {
  1052.       yyerror("parser stack overflow");
  1053.       return 2;
  1054.     }
  1055.       yystacksize *= 2;
  1056.       if (yystacksize > YYMAXDEPTH)
  1057.     yystacksize = YYMAXDEPTH;
  1058.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  1059.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  1060.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  1061.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  1062. #ifdef YYLSP_NEEDED
  1063.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  1064.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  1065. #endif
  1066. #endif /* no yyoverflow */
  1067.  
  1068.       yyssp = yyss + size - 1;
  1069.       yyvsp = yyvs + size - 1;
  1070. #ifdef YYLSP_NEEDED
  1071.       yylsp = yyls + size - 1;
  1072. #endif
  1073.  
  1074. #if YYDEBUG != 0
  1075.       if (yydebug)
  1076.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  1077. #endif
  1078.  
  1079.       if (yyssp >= yyss + yystacksize - 1)
  1080.     YYABORT;
  1081.     }
  1082.  
  1083. #if YYDEBUG != 0
  1084.   if (yydebug)
  1085.     fprintf(stderr, "Entering state %d\n", yystate);
  1086. #endif
  1087.  
  1088.  yybackup:
  1089.  
  1090. /* Do appropriate processing given the current state.  */
  1091. /* Read a lookahead token if we need one and don't already have one.  */
  1092. /* yyresume: */
  1093.  
  1094.   /* First try to decide what to do without reference to lookahead token.  */
  1095.  
  1096.   yyn = yypact[yystate];
  1097.   if (yyn == YYFLAG)
  1098.     goto yydefault;
  1099.  
  1100.   /* Not known => get a lookahead token if don't already have one.  */
  1101.  
  1102.   /* yychar is either YYEMPTY or YYEOF
  1103.      or a valid token in external form.  */
  1104.  
  1105.   if (yychar == YYEMPTY)
  1106.     {
  1107. #if YYDEBUG != 0
  1108.       if (yydebug)
  1109.     fprintf(stderr, "Reading a token: ");
  1110. #endif
  1111.       yychar = YYLEX;
  1112.     }
  1113.  
  1114.   /* Convert token to internal form (in yychar1) for indexing tables with */
  1115.  
  1116.   if (yychar <= 0)        /* This means end of input. */
  1117.     {
  1118.       yychar1 = 0;
  1119.       yychar = YYEOF;        /* Don't call YYLEX any more */
  1120.  
  1121. #if YYDEBUG != 0
  1122.       if (yydebug)
  1123.     fprintf(stderr, "Now at end of input.\n");
  1124. #endif
  1125.     }
  1126.   else
  1127.     {
  1128.       yychar1 = YYTRANSLATE(yychar);
  1129.  
  1130. #if YYDEBUG != 0
  1131.       if (yydebug)
  1132.     {
  1133.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  1134.       /* Give the individual parser a way to print the precise meaning
  1135.          of a token, for further debugging info.  */
  1136. #ifdef YYPRINT
  1137.       YYPRINT (stderr, yychar, yylval);
  1138. #endif
  1139.       fprintf (stderr, ")\n");
  1140.     }
  1141. #endif
  1142.     }
  1143.  
  1144.   yyn += yychar1;
  1145.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  1146.     goto yydefault;
  1147.  
  1148.   yyn = yytable[yyn];
  1149.  
  1150.   /* yyn is what to do for this token type in this state.
  1151.      Negative => reduce, -yyn is rule number.
  1152.      Positive => shift, yyn is new state.
  1153.        New state is final state => don't bother to shift,
  1154.        just return success.
  1155.      0, or most negative number => error.  */
  1156.  
  1157.   if (yyn < 0)
  1158.     {
  1159.       if (yyn == YYFLAG)
  1160.     goto yyerrlab;
  1161.       yyn = -yyn;
  1162.       goto yyreduce;
  1163.     }
  1164.   else if (yyn == 0)
  1165.     goto yyerrlab;
  1166.  
  1167.   if (yyn == YYFINAL)
  1168.     YYACCEPT;
  1169.  
  1170.   /* Shift the lookahead token.  */
  1171.  
  1172. #if YYDEBUG != 0
  1173.   if (yydebug)
  1174.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  1175. #endif
  1176.  
  1177.   /* Discard the token being shifted unless it is eof.  */
  1178.   if (yychar != YYEOF)
  1179.     yychar = YYEMPTY;
  1180.  
  1181.   *++yyvsp = yylval;
  1182. #ifdef YYLSP_NEEDED
  1183.   *++yylsp = yylloc;
  1184. #endif
  1185.  
  1186.   /* count tokens shifted since error; after three, turn off error status.  */
  1187.   if (yyerrstatus) yyerrstatus--;
  1188.  
  1189.   yystate = yyn;
  1190.   goto yynewstate;
  1191.  
  1192. /* Do the default action for the current state.  */
  1193. yydefault:
  1194.  
  1195.   yyn = yydefact[yystate];
  1196.   if (yyn == 0)
  1197.     goto yyerrlab;
  1198.  
  1199. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  1200. yyreduce:
  1201.   yylen = yyr2[yyn];
  1202.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  1203.  
  1204. #if YYDEBUG != 0
  1205.   if (yydebug)
  1206.     {
  1207.       int i;
  1208.  
  1209.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  1210.            yyn, yyrline[yyn]);
  1211.  
  1212.       /* Print the symboles being reduced, and their result.  */
  1213.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  1214.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  1215.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  1216.     }
  1217. #endif
  1218.  
  1219.  
  1220.   switch (yyn) {
  1221.  
  1222. case 1:
  1223. #line 137 "awk.y"
  1224. { expression_value = yyvsp[-1].nodeval; ;
  1225.     break;}
  1226. case 2:
  1227. #line 142 "awk.y"
  1228.             if (yyvsp[0].nodeval != NULL)
  1229.                 yyval.nodeval = yyvsp[0].nodeval;
  1230.             else
  1231.                 yyval.nodeval = NULL;
  1232.             yyerrok;
  1233.         ;
  1234.     break;}
  1235. case 3:
  1236. #line 151 "awk.y"
  1237. {
  1238.             if (yyvsp[0].nodeval == NULL)
  1239.                 yyval.nodeval = yyvsp[-1].nodeval;
  1240.             else if (yyvsp[-1].nodeval == NULL)
  1241.                 yyval.nodeval = yyvsp[0].nodeval;
  1242.             else {
  1243.                 if (yyvsp[-1].nodeval->type != Node_rule_list)
  1244.                     yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
  1245.                         (NODE*)NULL);
  1246.                 yyval.nodeval = append_right (yyvsp[-1].nodeval,
  1247.                    node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
  1248.             }
  1249.             yyerrok;
  1250.         ;
  1251.     break;}
  1252. case 4:
  1253. #line 165 "awk.y"
  1254. { yyval.nodeval = NULL; ;
  1255.     break;}
  1256. case 5:
  1257. #line 166 "awk.y"
  1258. { yyval.nodeval = NULL; ;
  1259.     break;}
  1260. case 6:
  1261. #line 170 "awk.y"
  1262. { io_allowed = 0; ;
  1263.     break;}
  1264. case 7:
  1265. #line 172 "awk.y"
  1266. {
  1267.         if (begin_block) {
  1268.             if (begin_block->type != Node_rule_list)
  1269.                 begin_block = node(begin_block, Node_rule_list,
  1270.                     (NODE *)NULL);
  1271.             (void) append_right (begin_block, node(
  1272.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1273.                 Node_rule_list, (NODE *)NULL) );
  1274.         } else
  1275.             begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1276.         yyval.nodeval = NULL;
  1277.         io_allowed = 1;
  1278.         yyerrok;
  1279.       ;
  1280.     break;}
  1281. case 8:
  1282. #line 186 "awk.y"
  1283. { io_allowed = 0; ;
  1284.     break;}
  1285. case 9:
  1286. #line 188 "awk.y"
  1287. {
  1288.         if (end_block) {
  1289.             if (end_block->type != Node_rule_list)
  1290.                 end_block = node(end_block, Node_rule_list,
  1291.                     (NODE *)NULL);
  1292.             (void) append_right (end_block, node(
  1293.                 node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
  1294.                 Node_rule_list, (NODE *)NULL));
  1295.         } else
  1296.             end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
  1297.         yyval.nodeval = NULL;
  1298.         io_allowed = 1;
  1299.         yyerrok;
  1300.       ;
  1301.     break;}
  1302. case 10:
  1303. #line 203 "awk.y"
  1304. {
  1305.         warning("BEGIN blocks must have an action part");
  1306.         errcount++;
  1307.         yyerrok;
  1308.       ;
  1309.     break;}
  1310. case 11:
  1311. #line 209 "awk.y"
  1312. {
  1313.         warning("END blocks must have an action part");
  1314.         errcount++;
  1315.         yyerrok;
  1316.       ;
  1317.     break;}
  1318. case 12:
  1319. #line 215 "awk.y"
  1320. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1321.     break;}
  1322. case 13:
  1323. #line 217 "awk.y"
  1324. { yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
  1325.     break;}
  1326. case 14:
  1327. #line 219 "awk.y"
  1328. {
  1329.           yyval.nodeval = node (yyvsp[-1].nodeval,
  1330.                  Node_rule_node,
  1331.                  node(node(node(make_number(0.0),
  1332.                         Node_field_spec,
  1333.                         (NODE *) NULL),
  1334.                     Node_expression_list,
  1335.                     (NODE *) NULL),
  1336.                   Node_K_print,
  1337.                   (NODE *) NULL));
  1338.           yyerrok;
  1339.         ;
  1340.     break;}
  1341. case 15:
  1342. #line 232 "awk.y"
  1343. {
  1344.             func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
  1345.             yyval.nodeval = NULL;
  1346.             yyerrok;
  1347.         ;
  1348.     break;}
  1349. case 16:
  1350. #line 241 "awk.y"
  1351. { yyval.sval = yyvsp[0].sval; ;
  1352.     break;}
  1353. case 17:
  1354. #line 243 "awk.y"
  1355. { yyval.sval = yyvsp[0].sval; ;
  1356.     break;}
  1357. case 18:
  1358. #line 245 "awk.y"
  1359. {
  1360.         yyerror("%s() is a built-in function, it cannot be redefined",
  1361.             tokstart);
  1362.         errcount++;
  1363.         /* yyerrok; */
  1364.       ;
  1365.     break;}
  1366. case 21:
  1367. #line 260 "awk.y"
  1368. {
  1369.             param_counter = 0;
  1370.         ;
  1371.     break;}
  1372. case 22:
  1373. #line 264 "awk.y"
  1374. {
  1375.             yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
  1376.             can_return = 1;
  1377.         ;
  1378.     break;}
  1379. case 23:
  1380. #line 272 "awk.y"
  1381. {
  1382.         yyval.nodeval = yyvsp[-2].nodeval;
  1383.         can_return = 0;
  1384.       ;
  1385.     break;}
  1386. case 24:
  1387. #line 281 "awk.y"
  1388. { yyval.nodeval = yyvsp[0].nodeval; ;
  1389.     break;}
  1390. case 25:
  1391. #line 283 "awk.y"
  1392. { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
  1393.     break;}
  1394. case 26:
  1395. #line 292 "awk.y"
  1396. { ++want_regexp; ;
  1397.     break;}
  1398. case 27:
  1399. #line 294 "awk.y"
  1400. {
  1401.           NODE *n;
  1402.  
  1403.           getnode(n);
  1404.           n->type = Node_regex;
  1405.           n->re_exp = make_string(yyvsp[-1].sval, strlen(yyvsp[-1].sval));
  1406.           n->re_reg = mk_re_parse(yyvsp[-1].sval, 0);
  1407.           n->re_text = NULL;
  1408.           n->re_flags = CONST;
  1409.           n->re_cnt = 1;
  1410.           yyval.nodeval = n;
  1411.         ;
  1412.     break;}
  1413. case 28:
  1414. #line 310 "awk.y"
  1415. { yyval.nodeval = yyvsp[-3].nodeval ; ;
  1416.     break;}
  1417. case 29:
  1418. #line 312 "awk.y"
  1419. { yyval.nodeval = NULL; ;
  1420.     break;}
  1421. case 30:
  1422. #line 317 "awk.y"
  1423. { yyval.nodeval = yyvsp[0].nodeval; ;
  1424.     break;}
  1425. case 31:
  1426. #line 319 "awk.y"
  1427. {
  1428.             if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
  1429.                 yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
  1430.                 yyval.nodeval = append_right(yyvsp[-1].nodeval,
  1431.                 node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
  1432.                 yyerrok;
  1433.         ;
  1434.     break;}
  1435. case 32:
  1436. #line 327 "awk.y"
  1437. { yyval.nodeval = NULL; ;
  1438.     break;}
  1439. case 33:
  1440. #line 329 "awk.y"
  1441. { yyval.nodeval = NULL; ;
  1442.     break;}
  1443. case 36:
  1444. #line 339 "awk.y"
  1445. { yyval.nodeval = NULL; ;
  1446.     break;}
  1447. case 37:
  1448. #line 341 "awk.y"
  1449. { yyval.nodeval = NULL; ;
  1450.     break;}
  1451. case 38:
  1452. #line 343 "awk.y"
  1453. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1454.     break;}
  1455. case 39:
  1456. #line 345 "awk.y"
  1457. { yyval.nodeval = yyvsp[0].nodeval; ;
  1458.     break;}
  1459. case 40:
  1460. #line 347 "awk.y"
  1461. { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
  1462.     break;}
  1463. case 41:
  1464. #line 349 "awk.y"
  1465. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
  1466.     break;}
  1467. case 42:
  1468. #line 351 "awk.y"
  1469. {
  1470.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval,1),
  1471.             (NODE *)NULL, variable(yyvsp[-3].sval,1)));
  1472.       ;
  1473.     break;}
  1474. case 43:
  1475. #line 356 "awk.y"
  1476. {
  1477.         yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
  1478.       ;
  1479.     break;}
  1480. case 44:
  1481. #line 360 "awk.y"
  1482. {
  1483.         yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
  1484.             (NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
  1485.       ;
  1486.     break;}
  1487. case 45:
  1488. #line 366 "awk.y"
  1489. { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
  1490.     break;}
  1491. case 46:
  1492. #line 369 "awk.y"
  1493. { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
  1494.     break;}
  1495. case 47:
  1496. #line 371 "awk.y"
  1497. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
  1498.     break;}
  1499. case 48:
  1500. #line 373 "awk.y"
  1501. {
  1502.             if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL)
  1503.                 yyvsp[-2].nodeval = node(node(make_number(0.0),
  1504.                            Node_field_spec,
  1505.                            (NODE *) NULL),
  1506.                       Node_expression_list,
  1507.                       (NODE *) NULL);
  1508.  
  1509.             yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
  1510.         ;
  1511.     break;}
  1512. case 49:
  1513. #line 384 "awk.y"
  1514. { NODETYPE type;
  1515.  
  1516.           if (! io_allowed) yyerror("next used in BEGIN or END action");
  1517.           if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) {
  1518.             if (do_lint)
  1519.                 warning("`next file' is a gawk extension");
  1520.             else if (strict || do_posix)
  1521.                 yyerror("`next file' is a gawk extension");
  1522.             type = Node_K_nextfile;
  1523.           } else type = Node_K_next;
  1524.           yyval.nodeval = node ((NODE *)NULL, type, (NODE *)NULL);
  1525.         ;
  1526.     break;}
  1527. case 50:
  1528. #line 397 "awk.y"
  1529. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
  1530.     break;}
  1531. case 51:
  1532. #line 399 "awk.y"
  1533. { if (! can_return) yyerror("return used outside function context"); ;
  1534.     break;}
  1535. case 52:
  1536. #line 401 "awk.y"
  1537. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
  1538.     break;}
  1539. case 53:
  1540. #line 403 "awk.y"
  1541. { yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ;
  1542.     break;}
  1543. case 54:
  1544. #line 405 "awk.y"
  1545. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1546.     break;}
  1547. case 55:
  1548. #line 410 "awk.y"
  1549. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1550.     break;}
  1551. case 56:
  1552. #line 412 "awk.y"
  1553. { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
  1554.     break;}
  1555. case 57:
  1556. #line 417 "awk.y"
  1557. {
  1558.         yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, 
  1559.             node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
  1560.       ;
  1561.     break;}
  1562. case 58:
  1563. #line 423 "awk.y"
  1564. { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
  1565.                 node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
  1566.     break;}
  1567. case 59:
  1568. #line 429 "awk.y"
  1569. { want_assign = 0; ;
  1570.     break;}
  1571. case 63:
  1572. #line 440 "awk.y"
  1573. { yyval.nodeval = NULL; ;
  1574.     break;}
  1575. case 64:
  1576. #line 442 "awk.y"
  1577. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
  1578.     break;}
  1579. case 65:
  1580. #line 447 "awk.y"
  1581. { yyval.nodeval = NULL; ;
  1582.     break;}
  1583. case 66:
  1584. #line 449 "awk.y"
  1585. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
  1586.     break;}
  1587. case 67:
  1588. #line 451 "awk.y"
  1589. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
  1590.     break;}
  1591. case 68:
  1592. #line 453 "awk.y"
  1593. { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
  1594.     break;}
  1595. case 69:
  1596. #line 458 "awk.y"
  1597. { yyval.nodeval = NULL; ;
  1598.     break;}
  1599. case 70:
  1600. #line 460 "awk.y"
  1601. { yyval.nodeval = yyvsp[0].nodeval; ;
  1602.     break;}
  1603. case 71:
  1604. #line 465 "awk.y"
  1605. { yyval.nodeval = make_param(yyvsp[0].sval); ;
  1606.     break;}
  1607. case 72:
  1608. #line 467 "awk.y"
  1609. { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
  1610.     break;}
  1611. case 73:
  1612. #line 469 "awk.y"
  1613. { yyval.nodeval = NULL; ;
  1614.     break;}
  1615. case 74:
  1616. #line 471 "awk.y"
  1617. { yyval.nodeval = NULL; ;
  1618.     break;}
  1619. case 75:
  1620. #line 473 "awk.y"
  1621. { yyval.nodeval = NULL; ;
  1622.     break;}
  1623. case 76:
  1624. #line 479 "awk.y"
  1625. { yyval.nodeval = NULL; ;
  1626.     break;}
  1627. case 77:
  1628. #line 481 "awk.y"
  1629. { yyval.nodeval = yyvsp[0].nodeval; ;
  1630.     break;}
  1631. case 78:
  1632. #line 486 "awk.y"
  1633. { yyval.nodeval = NULL; ;
  1634.     break;}
  1635. case 79:
  1636. #line 488 "awk.y"
  1637. { yyval.nodeval = yyvsp[0].nodeval; ;
  1638.     break;}
  1639. case 80:
  1640. #line 493 "awk.y"
  1641. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1642.     break;}
  1643. case 81:
  1644. #line 495 "awk.y"
  1645. {
  1646.         yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1647.             node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1648.         yyerrok;
  1649.       ;
  1650.     break;}
  1651. case 82:
  1652. #line 501 "awk.y"
  1653. { yyval.nodeval = NULL; ;
  1654.     break;}
  1655. case 83:
  1656. #line 503 "awk.y"
  1657. { yyval.nodeval = NULL; ;
  1658.     break;}
  1659. case 84:
  1660. #line 505 "awk.y"
  1661. { yyval.nodeval = NULL; ;
  1662.     break;}
  1663. case 85:
  1664. #line 507 "awk.y"
  1665. { yyval.nodeval = NULL; ;
  1666.     break;}
  1667. case 86:
  1668. #line 512 "awk.y"
  1669. { yyval.nodeval = NULL; ;
  1670.     break;}
  1671. case 87:
  1672. #line 514 "awk.y"
  1673. { yyval.nodeval = yyvsp[0].nodeval; ;
  1674.     break;}
  1675. case 88:
  1676. #line 519 "awk.y"
  1677. { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
  1678.     break;}
  1679. case 89:
  1680. #line 521 "awk.y"
  1681. {
  1682.             yyval.nodeval = append_right(yyvsp[-2].nodeval,
  1683.                 node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
  1684.             yyerrok;
  1685.         ;
  1686.     break;}
  1687. case 90:
  1688. #line 527 "awk.y"
  1689. { yyval.nodeval = NULL; ;
  1690.     break;}
  1691. case 91:
  1692. #line 529 "awk.y"
  1693. { yyval.nodeval = NULL; ;
  1694.     break;}
  1695. case 92:
  1696. #line 531 "awk.y"
  1697. { yyval.nodeval = NULL; ;
  1698.     break;}
  1699. case 93:
  1700. #line 533 "awk.y"
  1701. { yyval.nodeval = NULL; ;
  1702.     break;}
  1703. case 94:
  1704. #line 538 "awk.y"
  1705. { want_assign = 0; ;
  1706.     break;}
  1707. case 95:
  1708. #line 540 "awk.y"
  1709. {
  1710.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1711.             warning("Regular expression on left of assignment.");
  1712.           yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
  1713.         ;
  1714.     break;}
  1715. case 96:
  1716. #line 546 "awk.y"
  1717. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ;
  1718.     break;}
  1719. case 97:
  1720. #line 548 "awk.y"
  1721. {
  1722.           yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
  1723.              node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
  1724.         ;
  1725.     break;}
  1726. case 98:
  1727. #line 553 "awk.y"
  1728. {
  1729.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1730.             warning("non-redirected getline undefined inside BEGIN or END action");
  1731.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1732.         ;
  1733.     break;}
  1734. case 99:
  1735. #line 559 "awk.y"
  1736. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1737.     break;}
  1738. case 100:
  1739. #line 561 "awk.y"
  1740. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1741.     break;}
  1742. case 101:
  1743. #line 563 "awk.y"
  1744. {
  1745.           if (yyvsp[-2].nodeval->type == Node_regex)
  1746.             warning("Regular expression on left of MATCH operator.");
  1747.           yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
  1748.         ;
  1749.     break;}
  1750. case 102:
  1751. #line 569 "awk.y"
  1752. { yyval.nodeval = yyvsp[0].nodeval; ;
  1753.     break;}
  1754. case 103:
  1755. #line 571 "awk.y"
  1756. {
  1757.           yyval.nodeval = node(node(make_number(0.0),
  1758.                  Node_field_spec,
  1759.                  (NODE *) NULL),
  1760.                     Node_nomatch,
  1761.                 yyvsp[0].nodeval);
  1762.         ;
  1763.     break;}
  1764. case 104:
  1765. #line 579 "awk.y"
  1766. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
  1767.     break;}
  1768. case 105:
  1769. #line 581 "awk.y"
  1770. {
  1771.           if (do_lint && yyvsp[0].nodeval->type == Node_regex)
  1772.             warning("Regular expression on left of comparison.");
  1773.           yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
  1774.         ;
  1775.     break;}
  1776. case 106:
  1777. #line 587 "awk.y"
  1778. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
  1779.     break;}
  1780. case 107:
  1781. #line 589 "awk.y"
  1782. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
  1783.     break;}
  1784. case 108:
  1785. #line 591 "awk.y"
  1786. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1787.     break;}
  1788. case 109:
  1789. #line 593 "awk.y"
  1790. { yyval.nodeval = yyvsp[0].nodeval; ;
  1791.     break;}
  1792. case 110:
  1793. #line 595 "awk.y"
  1794. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1795.     break;}
  1796. case 111:
  1797. #line 600 "awk.y"
  1798. { want_assign = 0; ;
  1799.     break;}
  1800. case 112:
  1801. #line 602 "awk.y"
  1802. { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
  1803.     break;}
  1804. case 113:
  1805. #line 604 "awk.y"
  1806. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
  1807.     break;}
  1808. case 114:
  1809. #line 606 "awk.y"
  1810. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
  1811.     break;}
  1812. case 115:
  1813. #line 608 "awk.y"
  1814. {
  1815.           if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
  1816.             warning("non-redirected getline undefined inside BEGIN or END action");
  1817.           yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
  1818.         ;
  1819.     break;}
  1820. case 116:
  1821. #line 614 "awk.y"
  1822. { yyval.nodeval = yyvsp[0].nodeval; ;
  1823.     break;}
  1824. case 117:
  1825. #line 616 "awk.y"
  1826. { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
  1827.     break;}
  1828. case 118:
  1829. #line 618 "awk.y"
  1830. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
  1831.     break;}
  1832. case 119:
  1833. #line 620 "awk.y"
  1834. { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
  1835.     break;}
  1836. case 120:
  1837. #line 622 "awk.y"
  1838. { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
  1839.     break;}
  1840. case 121:
  1841. #line 624 "awk.y"
  1842. { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
  1843.     break;}
  1844. case 122:
  1845. #line 626 "awk.y"
  1846. { yyval.nodeval = yyvsp[0].nodeval; ;
  1847.     break;}
  1848. case 123:
  1849. #line 628 "awk.y"
  1850. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
  1851.     break;}
  1852. case 126:
  1853. #line 636 "awk.y"
  1854. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
  1855.     break;}
  1856. case 127:
  1857. #line 638 "awk.y"
  1858. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
  1859.     break;}
  1860. case 128:
  1861. #line 640 "awk.y"
  1862. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
  1863.     break;}
  1864. case 129:
  1865. #line 642 "awk.y"
  1866. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
  1867.     break;}
  1868. case 130:
  1869. #line 644 "awk.y"
  1870. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
  1871.     break;}
  1872. case 131:
  1873. #line 646 "awk.y"
  1874. { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
  1875.     break;}
  1876. case 132:
  1877. #line 651 "awk.y"
  1878. { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
  1879.     break;}
  1880. case 133:
  1881. #line 653 "awk.y"
  1882. { yyval.nodeval = yyvsp[-1].nodeval; ;
  1883.     break;}
  1884. case 134:
  1885. #line 655 "awk.y"
  1886.         if (! io_allowed && strcmp(tokstart, "nextfile") == 0)
  1887.             yyerror("nextfile() is illegal in BEGIN and END");
  1888.         ;
  1889.     break;}
  1890. case 135:
  1891. #line 660 "awk.y"
  1892. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-4].lval); ;
  1893.     break;}
  1894. case 136:
  1895. #line 662 "awk.y"
  1896. { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
  1897.     break;}
  1898. case 137:
  1899. #line 664 "awk.y"
  1900. {
  1901.         if (do_lint)
  1902.             warning("call of `length' without parentheses is not portable");
  1903.         yyval.nodeval = snode ((NODE *)NULL, Node_builtin, (int) yyvsp[0].lval);
  1904.         if (do_posix)
  1905.             warning( "call of `length' without parentheses is deprecated by POSIX");
  1906.       ;
  1907.     break;}
  1908. case 138:
  1909. #line 672 "awk.y"
  1910. {
  1911.         yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
  1912.       ;
  1913.     break;}
  1914. case 139:
  1915. #line 676 "awk.y"
  1916. { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
  1917.     break;}
  1918. case 140:
  1919. #line 678 "awk.y"
  1920. { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
  1921.     break;}
  1922. case 141:
  1923. #line 680 "awk.y"
  1924. { yyval.nodeval = yyvsp[0].nodeval; ;
  1925.     break;}
  1926. case 142:
  1927. #line 682 "awk.y"
  1928. { yyval.nodeval = yyvsp[0].nodeval; ;
  1929.     break;}
  1930. case 143:
  1931. #line 685 "awk.y"
  1932. { if (yyvsp[0].nodeval->type == Node_val) {
  1933.             yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
  1934.             yyval.nodeval = yyvsp[0].nodeval;
  1935.           } else
  1936.             yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL);
  1937.         ;
  1938.     break;}
  1939. case 144:
  1940. #line 692 "awk.y"
  1941. { yyval.nodeval = yyvsp[0].nodeval; ;
  1942.     break;}
  1943. case 145:
  1944. #line 697 "awk.y"
  1945. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
  1946.     break;}
  1947. case 146:
  1948. #line 699 "awk.y"
  1949. { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
  1950.     break;}
  1951. case 148:
  1952. #line 705 "awk.y"
  1953. { yyval.nodeval = NULL; ;
  1954.     break;}
  1955. case 149:
  1956. #line 707 "awk.y"
  1957. { yyval.nodeval = yyvsp[0].nodeval; ;
  1958.     break;}
  1959. case 150:
  1960. #line 712 "awk.y"
  1961. { yyval.nodeval = variable(yyvsp[0].sval,1); ;
  1962.     break;}
  1963. case 151:
  1964. #line 714 "awk.y"
  1965. {
  1966.         if (yyvsp[-1].nodeval->rnode == NULL) {
  1967.             yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval->lnode);
  1968.             freenode(yyvsp[-1].nodeval);
  1969.         } else
  1970.             yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval);
  1971.         ;
  1972.     break;}
  1973. case 152:
  1974. #line 722 "awk.y"
  1975. { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1976.     break;}
  1977. case 153:
  1978. #line 724 "awk.y"
  1979. { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
  1980.     break;}
  1981. case 155:
  1982. #line 732 "awk.y"
  1983. { yyerrok; ;
  1984.     break;}
  1985. case 156:
  1986. #line 736 "awk.y"
  1987. { yyerrok; ;
  1988.     break;}
  1989. case 159:
  1990. #line 745 "awk.y"
  1991. { yyerrok; want_assign = 0; ;
  1992.     break;}
  1993. case 160:
  1994. #line 748 "awk.y"
  1995. { yyerrok; ;
  1996.     break;}
  1997. }
  1998.    /* the action file gets copied in in place of this dollarsign */
  1999. #line 440 "bison.simple"
  2000.  
  2001.   yyvsp -= yylen;
  2002.   yyssp -= yylen;
  2003. #ifdef YYLSP_NEEDED
  2004.   yylsp -= yylen;
  2005. #endif
  2006.  
  2007. #if YYDEBUG != 0
  2008.   if (yydebug)
  2009.     {
  2010.       short *ssp1 = yyss - 1;
  2011.       fprintf (stderr, "state stack now");
  2012.       while (ssp1 != yyssp)
  2013.     fprintf (stderr, " %d", *++ssp1);
  2014.       fprintf (stderr, "\n");
  2015.     }
  2016. #endif
  2017.  
  2018.   *++yyvsp = yyval;
  2019.  
  2020. #ifdef YYLSP_NEEDED
  2021.   yylsp++;
  2022.   if (yylen == 0)
  2023.     {
  2024.       yylsp->first_line = yylloc.first_line;
  2025.       yylsp->first_column = yylloc.first_column;
  2026.       yylsp->last_line = (yylsp-1)->last_line;
  2027.       yylsp->last_column = (yylsp-1)->last_column;
  2028.       yylsp->text = 0;
  2029.     }
  2030.   else
  2031.     {
  2032.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  2033.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  2034.     }
  2035. #endif
  2036.  
  2037.   /* Now "shift" the result of the reduction.
  2038.      Determine what state that goes to,
  2039.      based on the state we popped back to
  2040.      and the rule number reduced by.  */
  2041.  
  2042.   yyn = yyr1[yyn];
  2043.  
  2044.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  2045.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  2046.     yystate = yytable[yystate];
  2047.   else
  2048.     yystate = yydefgoto[yyn - YYNTBASE];
  2049.  
  2050.   goto yynewstate;
  2051.  
  2052. yyerrlab:   /* here on detecting error */
  2053.  
  2054.   if (! yyerrstatus)
  2055.     /* If not already recovering from an error, report this error.  */
  2056.     {
  2057.       ++yynerrs;
  2058.  
  2059. #ifdef YYERROR_VERBOSE
  2060.       yyn = yypact[yystate];
  2061.  
  2062.       if (yyn > YYFLAG && yyn < YYLAST)
  2063.     {
  2064.       int size = 0;
  2065.       char *msg;
  2066.       int x, count;
  2067.  
  2068.       count = 0;
  2069.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  2070.         if (yycheck[x + yyn] == x)
  2071.           size += strlen(yytname[x]) + 15, count++;
  2072.       msg = (char *) xmalloc(size + 15);
  2073.       strcpy(msg, "parse error");
  2074.  
  2075.       if (count < 5)
  2076.         {
  2077.           count = 0;
  2078.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  2079.         if (yycheck[x + yyn] == x)
  2080.           {
  2081.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  2082.             strcat(msg, yytname[x]);
  2083.             strcat(msg, "'");
  2084.             count++;
  2085.           }
  2086.         }
  2087.       yyerror(msg);
  2088.       free(msg);
  2089.     }
  2090.       else
  2091. #endif /* YYERROR_VERBOSE */
  2092.     yyerror("parse error");
  2093.     }
  2094.  
  2095. yyerrlab1:   /* here on error raised explicitly by an action */
  2096.  
  2097.   if (yyerrstatus == 3)
  2098.     {
  2099.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  2100.  
  2101.       /* return failure if at end of input */
  2102.       if (yychar == YYEOF)
  2103.     YYABORT;
  2104.  
  2105. #if YYDEBUG != 0
  2106.       if (yydebug)
  2107.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  2108. #endif
  2109.  
  2110.       yychar = YYEMPTY;
  2111.     }
  2112.  
  2113.   /* Else will try to reuse lookahead token
  2114.      after shifting the error token.  */
  2115.  
  2116.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  2117.  
  2118.   goto yyerrhandle;
  2119.  
  2120. yyerrdefault:  /* current state does not do anything special for the error token. */
  2121.  
  2122. #if 0
  2123.   /* This is wrong; only states that explicitly want error tokens
  2124.      should shift them.  */
  2125.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  2126.   if (yyn) goto yydefault;
  2127. #endif
  2128.  
  2129. yyerrpop:   /* pop the current state because it cannot handle the error token */
  2130.  
  2131.   if (yyssp == yyss) YYABORT;
  2132.   yyvsp--;
  2133.   yystate = *--yyssp;
  2134. #ifdef YYLSP_NEEDED
  2135.   yylsp--;
  2136. #endif
  2137.  
  2138. #if YYDEBUG != 0
  2139.   if (yydebug)
  2140.     {
  2141.       short *ssp1 = yyss - 1;
  2142.       fprintf (stderr, "Error: state stack now");
  2143.       while (ssp1 != yyssp)
  2144.     fprintf (stderr, " %d", *++ssp1);
  2145.       fprintf (stderr, "\n");
  2146.     }
  2147. #endif
  2148.  
  2149. yyerrhandle:
  2150.  
  2151.   yyn = yypact[yystate];
  2152.   if (yyn == YYFLAG)
  2153.     goto yyerrdefault;
  2154.  
  2155.   yyn += YYTERROR;
  2156.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  2157.     goto yyerrdefault;
  2158.  
  2159.   yyn = yytable[yyn];
  2160.   if (yyn < 0)
  2161.     {
  2162.       if (yyn == YYFLAG)
  2163.     goto yyerrpop;
  2164.       yyn = -yyn;
  2165.       goto yyreduce;
  2166.     }
  2167.   else if (yyn == 0)
  2168.     goto yyerrpop;
  2169.  
  2170.   if (yyn == YYFINAL)
  2171.     YYACCEPT;
  2172.  
  2173. #if YYDEBUG != 0
  2174.   if (yydebug)
  2175.     fprintf(stderr, "Shifting error token, ");
  2176. #endif
  2177.  
  2178.   *++yyvsp = yylval;
  2179. #ifdef YYLSP_NEEDED
  2180.   *++yylsp = yylloc;
  2181. #endif
  2182.  
  2183.   yystate = yyn;
  2184.   goto yynewstate;
  2185. }
  2186. #line 751 "awk.y"
  2187.  
  2188.  
  2189. struct token {
  2190.     char *operator;        /* text to match */
  2191.     NODETYPE value;        /* node type */
  2192.     int class;        /* lexical class */
  2193.     unsigned flags;        /* # of args. allowed and compatability */
  2194. #    define    ARGS    0xFF    /* 0, 1, 2, 3 args allowed (any combination */
  2195. #    define    A(n)    (1<<(n))
  2196. #    define    VERSION    0xFF00    /* old awk is zero */
  2197. #    define    NOT_OLD        0x0100    /* feature not in old awk */
  2198. #    define    NOT_POSIX    0x0200    /* feature not in POSIX */
  2199. #    define    GAWKX        0x0400    /* gawk extension */
  2200.     NODE *(*ptr) ();    /* function that implements this keyword */
  2201. };
  2202.  
  2203. extern NODE
  2204.     *do_exp(),    *do_getline(),    *do_index(),    *do_length(),
  2205.     *do_sqrt(),    *do_log(),    *do_sprintf(),    *do_substr(),
  2206.     *do_split(),    *do_system(),    *do_int(),    *do_close(),
  2207.     *do_atan2(),    *do_sin(),    *do_cos(),    *do_rand(),
  2208.     *do_srand(),    *do_match(),    *do_tolower(),    *do_toupper(),
  2209.     *do_sub(),    *do_gsub(),    *do_strftime(),    *do_systime();
  2210.  
  2211. /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
  2212.  
  2213. static struct token tokentab[] = {
  2214. {"BEGIN",    Node_illegal,     LEX_BEGIN,    0,        0},
  2215. {"END",        Node_illegal,     LEX_END,    0,        0},
  2216. {"atan2",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_atan2},
  2217. {"break",    Node_K_break,     LEX_BREAK,    0,        0},
  2218. {"close",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_close},
  2219. {"continue",    Node_K_continue, LEX_CONTINUE,    0,        0},
  2220. {"cos",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_cos},
  2221. {"delete",    Node_K_delete,     LEX_DELETE,    NOT_OLD,    0},
  2222. {"do",        Node_K_do,     LEX_DO,    NOT_OLD,    0},
  2223. {"else",    Node_illegal,     LEX_ELSE,    0,        0},
  2224. {"exit",    Node_K_exit,     LEX_EXIT,    0,        0},
  2225. {"exp",        Node_builtin,     LEX_BUILTIN,    A(1),        do_exp},
  2226. {"for",        Node_K_for,     LEX_FOR,    0,        0},
  2227. {"func",    Node_K_function, LEX_FUNCTION,    NOT_POSIX|NOT_OLD,    0},
  2228. {"function",    Node_K_function, LEX_FUNCTION,    NOT_OLD,    0},
  2229. {"getline",    Node_K_getline,     LEX_GETLINE,    NOT_OLD,    0},
  2230. {"gsub",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_gsub},
  2231. {"if",        Node_K_if,     LEX_IF,    0,        0},
  2232. {"in",        Node_illegal,     LEX_IN,    0,        0},
  2233. {"index",    Node_builtin,     LEX_BUILTIN,    A(2),        do_index},
  2234. {"int",        Node_builtin,     LEX_BUILTIN,    A(1),        do_int},
  2235. {"length",    Node_builtin,     LEX_LENGTH,    A(0)|A(1),    do_length},
  2236. {"log",        Node_builtin,     LEX_BUILTIN,    A(1),        do_log},
  2237. {"match",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2),    do_match},
  2238. {"next",    Node_K_next,     LEX_NEXT,    0,        0},
  2239. {"print",    Node_K_print,     LEX_PRINT,    0,        0},
  2240. {"printf",    Node_K_printf,     LEX_PRINTF,    0,        0},
  2241. {"rand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0),    do_rand},
  2242. {"return",    Node_K_return,     LEX_RETURN,    NOT_OLD,    0},
  2243. {"sin",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_sin},
  2244. {"split",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_split},
  2245. {"sprintf",    Node_builtin,     LEX_BUILTIN,    0,        do_sprintf},
  2246. {"sqrt",    Node_builtin,     LEX_BUILTIN,    A(1),        do_sqrt},
  2247. {"srand",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(0)|A(1), do_srand},
  2248. {"strftime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(1)|A(2), do_strftime},
  2249. {"sub",        Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(2)|A(3), do_sub},
  2250. {"substr",    Node_builtin,     LEX_BUILTIN,    A(2)|A(3),    do_substr},
  2251. {"system",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_system},
  2252. {"systime",    Node_builtin,     LEX_BUILTIN,    GAWKX|A(0),    do_systime},
  2253. {"tolower",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_tolower},
  2254. {"toupper",    Node_builtin,     LEX_BUILTIN,    NOT_OLD|A(1),    do_toupper},
  2255. {"while",    Node_K_while,     LEX_WHILE,    0,        0},
  2256. };
  2257.  
  2258. /* VARARGS0 */
  2259. static void
  2260. yyerror(va_alist)
  2261. va_dcl
  2262. {
  2263.     va_list args;
  2264.     char *mesg;
  2265.     register char *bp, *cp;
  2266.     char *scan;
  2267.     char buf[120];
  2268.  
  2269.     errcount++;
  2270.     /* Find the current line in the input file */
  2271.     if (lexptr) {
  2272.         if (!thisline) {
  2273.             for (cp=lexeme; cp != lexptr_begin && *cp != '\n'; --cp)
  2274.                 ;
  2275.             if (*cp == '\n')
  2276.                 cp++;
  2277.             thisline = cp;
  2278.         }
  2279.         /* NL isn't guaranteed */
  2280.         bp = lexeme;
  2281.         while (bp < lexend && *bp && *bp != '\n')
  2282.             bp++;
  2283.     } else {
  2284.         thisline = "(END OF FILE)";
  2285.         bp = thisline + 13;
  2286.     }
  2287.     msg("%.*s", (int) (bp - thisline), thisline);
  2288.     bp = buf;
  2289.     cp = buf + sizeof(buf) - 24;    /* 24 more than longest msg. input */
  2290.     if (lexptr) {
  2291.         scan = thisline;
  2292.         while (bp < cp && scan < lexeme)
  2293.             if (*scan++ == '\t')
  2294.                 *bp++ = '\t';
  2295.             else
  2296.                 *bp++ = ' ';
  2297.         *bp++ = '^';
  2298.         *bp++ = ' ';
  2299.     }
  2300.     va_start(args);
  2301.     mesg = va_arg(args, char *);
  2302.     strcpy(bp, mesg);
  2303.     err("", buf, args);
  2304.     va_end(args);
  2305.     exit(2);
  2306. }
  2307.  
  2308. static char *
  2309. get_src_buf()
  2310. {
  2311.     static int samefile = 0;
  2312.     static int nextfile = 0;
  2313.     static char *buf = NULL;
  2314.     static int fd;
  2315.     int n;
  2316.     register char *scan;
  2317.     static int len = 0;
  2318.     static int did_newline = 0;
  2319. #    define    SLOP    128    /* enough space to hold most source lines */
  2320.  
  2321.     if (cmdline_src) {
  2322.         if (len == 0) {
  2323.             len = strlen(cmdline_src);
  2324.             if (len == 0)
  2325.                 cmdline_src = NULL;
  2326.             sourceline = 1;
  2327.             lexptr = lexptr_begin = cmdline_src;
  2328.             lexend = lexptr + len;
  2329.         } else if (!did_newline && *(lexptr-1) != '\n') {
  2330.             /*
  2331.              * The following goop is to ensure that the source
  2332.              * ends with a newline and that the entire current
  2333.              * line is available for error messages.
  2334.              */
  2335.             int offset;
  2336.  
  2337.             did_newline = 1;
  2338.             offset = lexptr - lexeme;
  2339.             for (scan = lexeme; scan > lexptr_begin; scan--)
  2340.                 if (*scan == '\n') {
  2341.                     scan++;
  2342.                     break;
  2343.                 }
  2344.             len = lexptr - scan;
  2345.             emalloc(buf, char *, len+1, "get_src_buf");
  2346.             memcpy(buf, scan, len);
  2347.             thisline = buf;
  2348.             lexptr = buf + len;
  2349.             *lexptr = '\n';
  2350.             lexeme = lexptr - offset;
  2351.             lexptr_begin = buf;
  2352.             lexend = lexptr + 1;
  2353.         } else
  2354.             lexeme = lexptr = lexptr_begin = NULL;
  2355.         return lexptr;
  2356.     }
  2357.     if (!samefile) {
  2358.         source = srcfiles[nextfile];
  2359.         if (source == NULL) {
  2360.             if (buf)
  2361.                 free(buf);
  2362.             return lexeme = lexptr = lexptr_begin = NULL;
  2363.         }
  2364.         fd = pathopen(source);
  2365.         if (fd == -1)
  2366.             fatal("can't open source file \"%s\" for reading (%s)",
  2367.                 source, strerror(errno));
  2368.         len = optimal_bufsize(fd);
  2369.         if (buf)
  2370.             free(buf);
  2371.         emalloc(buf, char *, len + SLOP, "get_src_buf");
  2372.         lexptr_begin = buf + SLOP;
  2373.         samefile = 1;
  2374.         sourceline = 1;
  2375.     } else {
  2376.         /*
  2377.          * Here, we retain the current source line (up to length SLOP)
  2378.          * in the beginning of the buffer that was overallocated above
  2379.          */
  2380.         int offset;
  2381.         int linelen;
  2382.  
  2383.         offset = lexptr - lexeme;
  2384.         for (scan = lexeme; scan > lexptr_begin; scan--)
  2385.             if (*scan == '\n') {
  2386.                 scan++;
  2387.                 break;
  2388.             }
  2389.         linelen = lexptr - scan;
  2390.         if (linelen > SLOP)
  2391.             len = SLOP;
  2392.         thisline = buf + SLOP - linelen;
  2393.         memcpy(thisline, scan, linelen);
  2394.         lexeme = buf + SLOP - offset;
  2395.         lexptr_begin = thisline;
  2396.     }
  2397.     n = read(fd, buf + SLOP, len);
  2398.     if (n == -1)
  2399.         fatal("can't read sourcefile \"%s\" (%s)",
  2400.             source, strerror(errno));
  2401.     if (n == 0) {
  2402.         samefile = 0;
  2403.         nextfile++;
  2404.         return get_src_buf();
  2405.     }
  2406.     lexptr = buf + SLOP;
  2407.     lexend = lexptr + n;
  2408.     return buf;
  2409. }
  2410.  
  2411. #define    tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token)
  2412.  
  2413. char *
  2414. tokexpand()
  2415. {
  2416.     static int toksize = 60;
  2417.     int tokoffset;
  2418.  
  2419.     tokoffset = token - tokstart;
  2420.     toksize *= 2;
  2421.     if (tokstart)
  2422.         erealloc(tokstart, char *, toksize, "tokexpand");
  2423.     else
  2424.         emalloc(tokstart, char *, toksize, "tokexpand");
  2425.     tokend = tokstart + toksize;
  2426.     token = tokstart + tokoffset;
  2427.     return token;
  2428. }
  2429.  
  2430. #ifdef DEBUG
  2431. char
  2432. nextc() {
  2433.     if (lexptr && lexptr < lexend)
  2434.         return *lexptr++;
  2435.     if (get_src_buf())
  2436.         return *lexptr++;
  2437.     return '\0';
  2438. }
  2439. #else
  2440. #define    nextc()    ((lexptr && lexptr < lexend) ? \
  2441.             *lexptr++ : \
  2442.             (get_src_buf() ? *lexptr++ : '\0') \
  2443.         )
  2444. #endif
  2445. #define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
  2446.  
  2447. /*
  2448.  * Read the input and turn it into tokens.
  2449.  */
  2450.  
  2451. static int
  2452. yylex()
  2453. {
  2454.     register int c;
  2455.     int seen_e = 0;        /* These are for numbers */
  2456.     int seen_point = 0;
  2457.     int esc_seen;        /* for literal strings */
  2458.     int low, mid, high;
  2459.     static int did_newline = 0;
  2460.     char *tokkey;
  2461.  
  2462.     if (!nextc())
  2463.         return 0;
  2464.     pushback();
  2465.     lexeme = lexptr;
  2466.     thisline = NULL;
  2467.     if (want_regexp) {
  2468.         int in_brack = 0;
  2469.  
  2470.         want_regexp = 0;
  2471.         token = tokstart;
  2472.         while ((c = nextc()) != 0) {
  2473.             switch (c) {
  2474.             case '[':
  2475.                 in_brack = 1;
  2476.                 break;
  2477.             case ']':
  2478.                 in_brack = 0;
  2479.                 break;
  2480.             case '\\':
  2481.                 if ((c = nextc()) == '\0') {
  2482.                     yyerror("unterminated regexp ends with \\ at end of file");
  2483.                 } else if (c == '\n') {
  2484.                     sourceline++;
  2485.                     continue;
  2486.                 } else
  2487.                     tokadd('\\');
  2488.                 break;
  2489.             case '/':    /* end of the regexp */
  2490.                 if (in_brack)
  2491.                     break;
  2492.  
  2493.                 pushback();
  2494.                 tokadd('\0');
  2495.                 yylval.sval = tokstart;
  2496.                 return REGEXP;
  2497.             case '\n':
  2498.                 pushback();
  2499.                 yyerror("unterminated regexp");
  2500.             case '\0':
  2501.                 yyerror("unterminated regexp at end of file");
  2502.             }
  2503.             tokadd(c);
  2504.         }
  2505.     }
  2506. retry:
  2507.     while ((c = nextc()) == ' ' || c == '\t')
  2508.         ;
  2509.  
  2510.     lexeme = lexptr-1;
  2511.     thisline = NULL;
  2512.     token = tokstart;
  2513.     yylval.nodetypeval = Node_illegal;
  2514.  
  2515.     switch (c) {
  2516.     case 0:
  2517.         return 0;
  2518.  
  2519.     case '\n':
  2520.         sourceline++;
  2521.         return NEWLINE;
  2522.  
  2523.     case '#':        /* it's a comment */
  2524.         while ((c = nextc()) != '\n') {
  2525.             if (c == '\0')
  2526.                 return 0;
  2527.         }
  2528.         sourceline++;
  2529.         return NEWLINE;
  2530.  
  2531.     case '\\':
  2532. #ifdef RELAXED_CONTINUATION
  2533.         if (!strict) {    /* strip trailing white-space and/or comment */
  2534.             while ((c = nextc()) == ' ' || c == '\t') continue;
  2535.             if (c == '#')
  2536.                 while ((c = nextc()) != '\n') if (!c) break;
  2537.             pushback();
  2538.         }
  2539. #endif /*RELAXED_CONTINUATION*/
  2540.         if (nextc() == '\n') {
  2541.             sourceline++;
  2542.             goto retry;
  2543.         } else
  2544.             yyerror("inappropriate use of backslash");
  2545.         break;
  2546.  
  2547.     case '$':
  2548.         want_assign = 1;
  2549.         return '$';
  2550.  
  2551.     case ')':
  2552.     case ']':
  2553.     case '(':    
  2554.     case '[':
  2555.     case ';':
  2556.     case ':':
  2557.     case '?':
  2558.     case '{':
  2559.     case ',':
  2560.         return c;
  2561.  
  2562.     case '*':
  2563.         if ((c = nextc()) == '=') {
  2564.             yylval.nodetypeval = Node_assign_times;
  2565.             return ASSIGNOP;
  2566.         } else if (do_posix) {
  2567.             pushback();
  2568.             return '*';
  2569.         } else if (c == '*') {
  2570.             /* make ** and **= aliases for ^ and ^= */
  2571.             static int did_warn_op = 0, did_warn_assgn = 0;
  2572.  
  2573.             if (nextc() == '=') {
  2574.                 if (do_lint && ! did_warn_assgn) {
  2575.                     did_warn_assgn = 1;
  2576.                     warning("**= is not allowed by POSIX");
  2577.                 }
  2578.                 yylval.nodetypeval = Node_assign_exp;
  2579.                 return ASSIGNOP;
  2580.             } else {
  2581.                 pushback();
  2582.                 if (do_lint && ! did_warn_op) {
  2583.                     did_warn_op = 1;
  2584.                     warning("** is not allowed by POSIX");
  2585.                 }
  2586.                 return '^';
  2587.             }
  2588.         }
  2589.         pushback();
  2590.         return '*';
  2591.  
  2592.     case '/':
  2593.         if (want_assign) {
  2594.             if (nextc() == '=') {
  2595.                 yylval.nodetypeval = Node_assign_quotient;
  2596.                 return ASSIGNOP;
  2597.             }
  2598.             pushback();
  2599.         }
  2600.         return '/';
  2601.  
  2602.     case '%':
  2603.         if (nextc() == '=') {
  2604.             yylval.nodetypeval = Node_assign_mod;
  2605.             return ASSIGNOP;
  2606.         }
  2607.         pushback();
  2608.         return '%';
  2609.  
  2610.     case '^':
  2611.     {
  2612.         static int did_warn_op = 0, did_warn_assgn = 0;
  2613.  
  2614.         if (nextc() == '=') {
  2615.  
  2616.             if (do_lint && ! did_warn_assgn) {
  2617.                 did_warn_assgn = 1;
  2618.                 warning("operator `^=' is not supported in old awk");
  2619.             }
  2620.             yylval.nodetypeval = Node_assign_exp;
  2621.             return ASSIGNOP;
  2622.         }
  2623.         pushback();
  2624.         if (do_lint && ! did_warn_op) {
  2625.             did_warn_op = 1;
  2626.             warning("operator `^' is not supported in old awk");
  2627.         }
  2628.         return '^';
  2629.     }
  2630.  
  2631.     case '+':
  2632.         if ((c = nextc()) == '=') {
  2633.             yylval.nodetypeval = Node_assign_plus;
  2634.             return ASSIGNOP;
  2635.         }
  2636.         if (c == '+')
  2637.             return INCREMENT;
  2638.         pushback();
  2639.         return '+';
  2640.  
  2641.     case '!':
  2642.         if ((c = nextc()) == '=') {
  2643.             yylval.nodetypeval = Node_notequal;
  2644.             return RELOP;
  2645.         }
  2646.         if (c == '~') {
  2647.             yylval.nodetypeval = Node_nomatch;
  2648.             want_assign = 0;
  2649.             return MATCHOP;
  2650.         }
  2651.         pushback();
  2652.         return '!';
  2653.  
  2654.     case '<':
  2655.         if (nextc() == '=') {
  2656.             yylval.nodetypeval = Node_leq;
  2657.             return RELOP;
  2658.         }
  2659.         yylval.nodetypeval = Node_less;
  2660.         pushback();
  2661.         return '<';
  2662.  
  2663.     case '=':
  2664.         if (nextc() == '=') {
  2665.             yylval.nodetypeval = Node_equal;
  2666.             return RELOP;
  2667.         }
  2668.         yylval.nodetypeval = Node_assign;
  2669.         pushback();
  2670.         return ASSIGNOP;
  2671.  
  2672.     case '>':
  2673.         if ((c = nextc()) == '=') {
  2674.             yylval.nodetypeval = Node_geq;
  2675.             return RELOP;
  2676.         } else if (c == '>') {
  2677.             yylval.nodetypeval = Node_redirect_append;
  2678.             return APPEND_OP;
  2679.         }
  2680.         yylval.nodetypeval = Node_greater;
  2681.         pushback();
  2682.         return '>';
  2683.  
  2684.     case '~':
  2685.         yylval.nodetypeval = Node_match;
  2686.         want_assign = 0;
  2687.         return MATCHOP;
  2688.  
  2689.     case '}':
  2690.         /*
  2691.          * Added did newline stuff.  Easier than
  2692.          * hacking the grammar
  2693.          */
  2694.         if (did_newline) {
  2695.             did_newline = 0;
  2696.             return c;
  2697.         }
  2698.         did_newline++;
  2699.         --lexptr;    /* pick up } next time */
  2700.         return NEWLINE;
  2701.  
  2702.     case '"':
  2703.         esc_seen = 0;
  2704.         while ((c = nextc()) != '"') {
  2705.             if (c == '\n') {
  2706.                 pushback();
  2707.                 yyerror("unterminated string");
  2708.             }
  2709.             if (c == '\\') {
  2710.                 c = nextc();
  2711.                 if (c == '\n') {
  2712.                     sourceline++;
  2713.                     continue;
  2714.                 }
  2715.                 esc_seen = 1;
  2716.                 tokadd('\\');
  2717.             }
  2718.             if (c == '\0') {
  2719.                 pushback();
  2720.                 yyerror("unterminated string");
  2721.             }
  2722.             tokadd(c);
  2723.         }
  2724.         yylval.nodeval = make_str_node(tokstart,
  2725.                     token - tokstart, esc_seen ? SCAN : 0);
  2726.         yylval.nodeval->flags |= PERM;
  2727.         return YSTRING;
  2728.  
  2729.     case '-':
  2730.         if ((c = nextc()) == '=') {
  2731.             yylval.nodetypeval = Node_assign_minus;
  2732.             return ASSIGNOP;
  2733.         }
  2734.         if (c == '-')
  2735.             return DECREMENT;
  2736.         pushback();
  2737.         return '-';
  2738.  
  2739.     case '.':
  2740.         c = nextc();
  2741.         pushback();
  2742.         if (!isdigit(c))
  2743.             return '.';
  2744.         else
  2745.             c = '.';    /* FALL THROUGH */
  2746.     case '0':
  2747.     case '1':
  2748.     case '2':
  2749.     case '3':
  2750.     case '4':
  2751.     case '5':
  2752.     case '6':
  2753.     case '7':
  2754.     case '8':
  2755.     case '9':
  2756.         /* It's a number */
  2757.         for (;;) {
  2758.             int gotnumber = 0;
  2759.  
  2760.             tokadd(c);
  2761.             switch (c) {
  2762.             case '.':
  2763.                 if (seen_point) {
  2764.                     gotnumber++;
  2765.                     break;
  2766.                 }
  2767.                 ++seen_point;
  2768.                 break;
  2769.             case 'e':
  2770.             case 'E':
  2771.                 if (seen_e) {
  2772.                     gotnumber++;
  2773.                     break;
  2774.                 }
  2775.                 ++seen_e;
  2776.                 if ((c = nextc()) == '-' || c == '+')
  2777.                     tokadd(c);
  2778.                 else
  2779.                     pushback();
  2780.                 break;
  2781.             case '0':
  2782.             case '1':
  2783.             case '2':
  2784.             case '3':
  2785.             case '4':
  2786.             case '5':
  2787.             case '6':
  2788.             case '7':
  2789.             case '8':
  2790.             case '9':
  2791.                 break;
  2792.             default:
  2793.                 gotnumber++;
  2794.             }
  2795.             if (gotnumber)
  2796.                 break;
  2797.             c = nextc();
  2798.         }
  2799.         pushback();
  2800.         yylval.nodeval = make_number(atof(tokstart));
  2801.         yylval.nodeval->flags |= PERM;
  2802.         return YNUMBER;
  2803.  
  2804.     case '&':
  2805.         if ((c = nextc()) == '&') {
  2806.             yylval.nodetypeval = Node_and;
  2807.             for (;;) {
  2808.                 c = nextc();
  2809.                 if (c == '\0')
  2810.                     break;
  2811.                 if (c == '#') {
  2812.                     while ((c = nextc()) != '\n' && c != '\0')
  2813.                         ;
  2814.                     if (c == '\0')
  2815.                         break;
  2816.                 }
  2817.                 if (c == '\n')
  2818.                     sourceline++;
  2819.                 if (! isspace(c)) {
  2820.                     pushback();
  2821.                     break;
  2822.                 }
  2823.             }
  2824.             want_assign = 0;
  2825.             return LEX_AND;
  2826.         }
  2827.         pushback();
  2828.         return '&';
  2829.  
  2830.     case '|':
  2831.         if ((c = nextc()) == '|') {
  2832.             yylval.nodetypeval = Node_or;
  2833.             for (;;) {
  2834.                 c = nextc();
  2835.                 if (c == '\0')
  2836.                     break;
  2837.                 if (c == '#') {
  2838.                     while ((c = nextc()) != '\n' && c != '\0')
  2839.                         ;
  2840.                     if (c == '\0')
  2841.                         break;
  2842.                 }
  2843.                 if (c == '\n')
  2844.                     sourceline++;
  2845.                 if (! isspace(c)) {
  2846.                     pushback();
  2847.                     break;
  2848.                 }
  2849.             }
  2850.             want_assign = 0;
  2851.             return LEX_OR;
  2852.         }
  2853.         pushback();
  2854.         return '|';
  2855.     }
  2856.  
  2857.     if (c != '_' && ! isalpha(c))
  2858.         yyerror("Invalid char '%c' in expression\n", c);
  2859.  
  2860.     /* it's some type of name-type-thing.  Find its length */
  2861.     token = tokstart;
  2862.     while (is_identchar(c)) {
  2863.         tokadd(c);
  2864.         c = nextc();
  2865.     }
  2866.     tokadd('\0');
  2867.     emalloc(tokkey, char *, token - tokstart, "yylex");
  2868.     memcpy(tokkey, tokstart, token - tokstart);
  2869.     pushback();
  2870.  
  2871.     /* See if it is a special token.  */
  2872.     low = 0;
  2873.     high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
  2874.     while (low <= high) {
  2875.         int i/* , c */;
  2876.  
  2877.         mid = (low + high) / 2;
  2878.         c = *tokstart - tokentab[mid].operator[0];
  2879.         i = c ? c : strcmp (tokstart, tokentab[mid].operator);
  2880.  
  2881.         if (i < 0) {        /* token < mid */
  2882.             high = mid - 1;
  2883.         } else if (i > 0) {    /* token > mid */
  2884.             low = mid + 1;
  2885.         } else {
  2886.             if (do_lint) {
  2887.                 if (tokentab[mid].flags & GAWKX)
  2888.                     warning("%s() is a gawk extension",
  2889.                         tokentab[mid].operator);
  2890.                 if (tokentab[mid].flags & NOT_POSIX)
  2891.                     warning("POSIX does not allow %s",
  2892.                         tokentab[mid].operator);
  2893.                 if (tokentab[mid].flags & NOT_OLD)
  2894.                     warning("%s is not supported in old awk",
  2895.                         tokentab[mid].operator);
  2896.             }
  2897.             if ((strict && (tokentab[mid].flags & GAWKX))
  2898.                 || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
  2899.                 break;
  2900.             if (tokentab[mid].class == LEX_BUILTIN
  2901.                 || tokentab[mid].class == LEX_LENGTH
  2902.                )
  2903.                 yylval.lval = mid;
  2904.             else
  2905.                 yylval.nodetypeval = tokentab[mid].value;
  2906.  
  2907.             return tokentab[mid].class;
  2908.         }
  2909.     }
  2910.  
  2911.     yylval.sval = tokkey;
  2912.     if (*lexptr == '(')
  2913.         return FUNC_CALL;
  2914.     else {
  2915.         want_assign = 1;
  2916.         return NAME;
  2917.     }
  2918. }
  2919.  
  2920. static NODE *
  2921. node_common(op)
  2922. NODETYPE op;
  2923. {
  2924.     register NODE *r;
  2925.  
  2926.     getnode(r);
  2927.     r->type = op;
  2928.     r->flags = MALLOC;
  2929.     /* if lookahead is NL, lineno is 1 too high */
  2930.     if (lexeme && *lexeme == '\n')
  2931.         r->source_line = sourceline - 1;
  2932.     else
  2933.         r->source_line = sourceline;
  2934.     r->source_file = source;
  2935.     return r;
  2936. }
  2937.  
  2938. /*
  2939.  * This allocates a node with defined lnode and rnode. 
  2940.  */
  2941. NODE *
  2942. node(left, op, right)
  2943. NODE *left, *right;
  2944. NODETYPE op;
  2945. {
  2946.     register NODE *r;
  2947.  
  2948.     r = node_common(op);
  2949.     r->lnode = left;
  2950.     r->rnode = right;
  2951.     return r;
  2952. }
  2953.  
  2954. /*
  2955.  * This allocates a node with defined subnode and proc for builtin functions
  2956.  * Checks for arg. count and supplies defaults where possible.
  2957.  */
  2958. static NODE *
  2959. snode(subn, op, idx)
  2960. NODETYPE op;
  2961. int idx;
  2962. NODE *subn;
  2963. {
  2964.     register NODE *r;
  2965.     register NODE *n;
  2966.     int nexp = 0;
  2967.     int args_allowed;
  2968.  
  2969.     r = node_common(op);
  2970.  
  2971.     /* traverse expression list to see how many args. given */
  2972.     for (n= subn; n; n= n->rnode) {
  2973.         nexp++;
  2974.         if (nexp > 3)
  2975.             break;
  2976.     }
  2977.  
  2978.     /* check against how many args. are allowed for this builtin */
  2979.     args_allowed = tokentab[idx].flags & ARGS;
  2980.     if (args_allowed && !(args_allowed & A(nexp)))
  2981.         fatal("%s() cannot have %d argument%c",
  2982.             tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
  2983.  
  2984.     r->proc = tokentab[idx].ptr;
  2985.  
  2986.     /* special case processing for a few builtins */
  2987.     if (nexp == 0 && r->proc == do_length) {
  2988.         subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
  2989.                     Node_expression_list,
  2990.                 (NODE *) NULL);
  2991.     } else if (r->proc == do_match) {
  2992.         if (subn->rnode->lnode->type != Node_regex)
  2993.             subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
  2994.     } else if (r->proc == do_sub || r->proc == do_gsub) {
  2995.         if (subn->lnode->type != Node_regex)
  2996.             subn->lnode = mk_rexp(subn->lnode);
  2997.         if (nexp == 2)
  2998.             append_right(subn, node(node(make_number(0.0),
  2999.                              Node_field_spec,
  3000.                              (NODE *) NULL),
  3001.                             Node_expression_list,
  3002.                         (NODE *) NULL));
  3003.         else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
  3004.             warning("string literal as last arg of substitute");
  3005.     } else if (r->proc == do_split) {
  3006.         if (nexp == 2)
  3007.             append_right(subn,
  3008.                 node(FS_node, Node_expression_list, (NODE *) NULL));
  3009.         n = subn->rnode->rnode->lnode;
  3010.         if (n->type != Node_regex)
  3011.             subn->rnode->rnode->lnode = mk_rexp(n);
  3012.         if (nexp == 2)
  3013.             subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
  3014.     }
  3015.  
  3016.     r->subnode = subn;
  3017.     return r;
  3018. }
  3019.  
  3020. /*
  3021.  * This allocates a Node_line_range node with defined condpair and
  3022.  * zeroes the trigger word to avoid the temptation of assuming that calling
  3023.  * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'. 
  3024.  */
  3025. /* Otherwise like node() */
  3026. static NODE *
  3027. mkrangenode(cpair)
  3028. NODE *cpair;
  3029. {
  3030.     register NODE *r;
  3031.  
  3032.     getnode(r);
  3033.     r->type = Node_line_range;
  3034.     r->condpair = cpair;
  3035.     r->triggered = 0;
  3036.     return r;
  3037. }
  3038.  
  3039. /* Build a for loop */
  3040. static NODE *
  3041. make_for_loop(init, cond, incr)
  3042. NODE *init, *cond, *incr;
  3043. {
  3044.     register FOR_LOOP_HEADER *r;
  3045.     NODE *n;
  3046.  
  3047.     emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
  3048.     getnode(n);
  3049.     n->type = Node_illegal;
  3050.     r->init = init;
  3051.     r->cond = cond;
  3052.     r->incr = incr;
  3053.     n->sub.nodep.r.hd = r;
  3054.     return n;
  3055. }
  3056.  
  3057. /*
  3058.  * Install a name in the symbol table, even if it is already there.
  3059.  * Caller must check against redefinition if that is desired. 
  3060.  */
  3061. NODE *
  3062. install(name, value)
  3063. char *name;
  3064. NODE *value;
  3065. {
  3066.     register NODE *hp;
  3067.     register int len, bucket;
  3068.  
  3069.     len = strlen(name);
  3070.     bucket = hash(name, len);
  3071.     getnode(hp);
  3072.     hp->type = Node_hashnode;
  3073.     hp->hnext = variables[bucket];
  3074.     variables[bucket] = hp;
  3075.     hp->hlength = len;
  3076.     hp->hvalue = value;
  3077.     hp->hname = name;
  3078.     return hp->hvalue;
  3079. }
  3080.  
  3081. /* find the most recent hash node for name installed by install */
  3082. NODE *
  3083. lookup(name)
  3084. char *name;
  3085. {
  3086.     register NODE *bucket;
  3087.     register int len;
  3088.  
  3089.     len = strlen(name);
  3090.     bucket = variables[hash(name, len)];
  3091.     while (bucket) {
  3092.         if (bucket->hlength == len && STREQN(bucket->hname, name, len))
  3093.             return bucket->hvalue;
  3094.         bucket = bucket->hnext;
  3095.     }
  3096.     return NULL;
  3097. }
  3098.  
  3099. /*
  3100.  * Add new to the rightmost branch of LIST.  This uses n^2 time, so we make
  3101.  * a simple attempt at optimizing it.
  3102.  */
  3103. static NODE *
  3104. append_right(list, new)
  3105. NODE *list, *new;
  3106. {
  3107.     register NODE *oldlist;
  3108.     static NODE *savefront = NULL, *savetail = NULL;
  3109.  
  3110.     oldlist = list;
  3111.     if (savefront == oldlist) {
  3112.         savetail = savetail->rnode = new;
  3113.         return oldlist;
  3114.     } else
  3115.         savefront = oldlist;
  3116.     while (list->rnode != NULL)
  3117.         list = list->rnode;
  3118.     savetail = list->rnode = new;
  3119.     return oldlist;
  3120. }
  3121.  
  3122. /*
  3123.  * check if name is already installed;  if so, it had better have Null value,
  3124.  * in which case def is added as the value. Otherwise, install name with def
  3125.  * as value. 
  3126.  */
  3127. static void
  3128. func_install(params, def)
  3129. NODE *params;
  3130. NODE *def;
  3131. {
  3132.     NODE *r;
  3133.  
  3134.     pop_params(params->rnode);
  3135.     pop_var(params, 0);
  3136.     r = lookup(params->param);
  3137.     if (r != NULL) {
  3138.         fatal("function name `%s' previously defined", params->param);
  3139.     } else
  3140.         (void) install(params->param, node(params, Node_func, def));
  3141. }
  3142.  
  3143. static void
  3144. pop_var(np, freeit)
  3145. NODE *np;
  3146. int freeit;
  3147. {
  3148.     register NODE *bucket, **save;
  3149.     register int len;
  3150.     char *name;
  3151.  
  3152.     name = np->param;
  3153.     len = strlen(name);
  3154.     save = &(variables[hash(name, len)]);
  3155.     for (bucket = *save; bucket; bucket = bucket->hnext) {
  3156.         if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
  3157.             *save = bucket->hnext;
  3158.             freenode(bucket);
  3159.             if (freeit)
  3160.                 free(np->param);
  3161.             return;
  3162.         }
  3163.         save = &(bucket->hnext);
  3164.     }
  3165. }
  3166.  
  3167. static void
  3168. pop_params(params)
  3169. NODE *params;
  3170. {
  3171.     register NODE *np;
  3172.  
  3173.     for (np = params; np != NULL; np = np->rnode)
  3174.         pop_var(np, 1);
  3175. }
  3176.  
  3177. static NODE *
  3178. make_param(name)
  3179. char *name;
  3180. {
  3181.     NODE *r;
  3182.  
  3183.     getnode(r);
  3184.     r->type = Node_param_list;
  3185.     r->rnode = NULL;
  3186.     r->param = name;
  3187.     r->param_cnt = param_counter++;
  3188.     return (install(name, r));
  3189. }
  3190.  
  3191. /* Name points to a variable name.  Make sure its in the symbol table */
  3192. NODE *
  3193. variable(name, can_free)
  3194. char *name;
  3195. int can_free;
  3196. {
  3197.     register NODE *r;
  3198.     static int env_loaded = 0;
  3199.  
  3200.     if (!env_loaded && STREQ(name, "ENVIRON")) {
  3201.         load_environ();
  3202.         env_loaded = 1;
  3203.     }
  3204.     if ((r = lookup(name)) == NULL)
  3205.         r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
  3206.     else if (can_free)
  3207.         free(name);
  3208.     return r;
  3209. }
  3210.  
  3211. static NODE *
  3212. mk_rexp(exp)
  3213. NODE *exp;
  3214. {
  3215.     if (exp->type == Node_regex)
  3216.         return exp;
  3217.     else {
  3218.         NODE *n;
  3219.  
  3220.         getnode(n);
  3221.         n->type = Node_regex;
  3222.         n->re_exp = exp;
  3223.         n->re_text = NULL;
  3224.         n->re_reg = NULL;
  3225.         n->re_flags = 0;
  3226.         n->re_cnt = 1;
  3227.         return n;
  3228.     }
  3229. }
  3230.